Re: gec: Is it possible to specify a signature for a external C call?
Berend de Boer <[email protected]> Tue, 13 Nov 2007 11:51:06 +1300
| Newsgroups | gmane.comp.lang.eiffel.gobo.general |
|---|---|
| Message-ID | <[email protected]> |
>>>>> "Eric" == Eric Bezault <ericb-D6Qt/9opevxWk0Htik3J/[email protected]> writes: >> You think this is a hard piece to add to gec? Eric> It is probably not hard to add. It's just that I'm not sure Eric> this is the right thing to do. If you don't want to write a Eric> header file, then I think that it would be better to use Eric> ECMA's "C inline" external routines. Which isn't an option if you want to link to Pascal or Fortran libraries. Eric> The fact that it works with SmartEiffel and ISE Eiffel is just Eric> luck in my opinion. It works, because they emit a prototype. That had to be coded, so it's not luck. Eric> Does it work as well when you add assertions to these Eric> external routines? Yes. The created prototypes are just for the called external function. Eric> Are these prototypes only added when the external routines do Eric> not specify any header files, or do they appear also when Eric> there is a header file specified? Here SE's 1.2r7 code: /* Extra external prototype for line 34 of /home/berend/src/eposix/src/capi/spec/se/capi_time.e:*/ T5 posix_difftime(T2 a1,T2 a2); If I put in a (dummy) header: external "C use <time.h>" I get this: /*l34c12/capi_time.e*/#ifdef __cplusplus } #endif #include <time.h> #ifdef __cplusplus extern "C" { #endif /*l34c12/capi_time.e*//*POSIX_TIME*/ For ISE it generates the prototype in a .c file: extern EIF_REAL_64 posix_difftime(EIF_INTEGER_32, EIF_INTEGER_32); If I add a header with: external "C use <time.h>" No such prototype is created. So their behaviour is intentional and it allows everyone to link to libraries without having to know how to write header files (or having to distribute them if you distribute your C code). -- Cheers, Berend de Boer [Non-text portions of this message have been removed]