Re: gec: Is it possible to specify a signature for a external C call?
Eric Bezault <ericb-D6Qt/9opevxWk0Htik3J/[email protected]> Mon, 12 Nov 2007 18:17:36 +0100
| Newsgroups | gmane.comp.lang.eiffel.gobo.general |
|---|---|
| Message-ID | <[email protected]> |
Berend de Boer wrote: >>>>>> "Eric" == Eric Bezault <ericb-D6Qt/9opevxWk0Htik3J/[email protected]> writes: > > Eric> When you wrote 'posix_difftime', you should have written a > Eric> prototype for it in some header file as well. So what you have > Eric> to do is: > > Eric> posix_difftime (time_end, time_start: INTEGER): DOUBLE is > Eric> external "C use %"some_header_file.h%"" end > > Eric> where 'some_header_file.h' is your header file. > > That hasn't been necessary for any other Eiffel compiler so far. > > So I think more people might run into this issue. > > And for a wrapper library like POSIX that is kinda hard. The header file > might depend on the platform. So that means creating another header > which will include ge_eiffel.h, because I work with Eiffel types such as > EIF_INTEGER as parameter. > > But that will redefine EIF_INTEGER and probably lots of other types > which are included in the generated .h file. Which leads to clashes I'm > afraid. > > So I think creating a prototype in the .h is the best approach, and I > refer to SmartEiffel and ISE Eiffel which do this. > > I could work a bit on this if you are convinced that this is the > approach that makes integration with C libraries as easy as possible. It > is, because you can link to any c (or Pascal/Fortran/whatever lib > without having to write a .h file). > > You think this is a hard piece to add to gec? It is probably not hard to add. It's just that I'm not sure this is the right thing to do. If you don't want to write a header file, then I think that it would be better to use ECMA's "C inline" external routines. The fact that it works with SmartEiffel and ISE Eiffel is just luck in my opinion. Does it work as well when you add assertions to these external routines? Are these prototypes only added when the external routines do not specify any header files, or do they appear also when there is a header file specified? -- Eric Bezault mailto:ericb-D6Qt/9opevxWk0Htik3J/[email protected] http://www.gobosoft.com