paj@hic.uucp (Paul Johnson) (03/22/90)
I have been using gcc for Eiffel C compilation, and am posting my experiences for the benefit of the net (along with a query): As it says in the Environment manual, set the environment variables "C_COMPILER" and "LINK_EDITOR" to the compiler plus command line arguments. The arguments I am currently using are: -g I know about not using dbx to debug Eiffel, but once in a while I get a segmentation violation, and dbx is the easiest way to find out what has gone wrong. -traditional If you have a look at the "Incompatabilities" section of the GCC manual, it lists a lot of little things which are changed back by this flag. Whether any of them matter is a good question. The differences are: - Quoted macro argument substitution. - Rregister allocation in routines using setjmp (Eiffel uses setjmp for exception handling: see "_eiffel.h"). - extern funtion scope. - Unterminated character strings in failed #if constructs are caught. - Float/double parameter conversions. -fpcc-struct-return This tells gcc to return structures and unions in the same way as most C compilers. This involves putting the structure in a static buffer and returning a pointer to it. Gcc functions take an implicit argument pointing to the eventual destination of the result. This is both faster and reentrant. This may affect programs with modules compiled under a mixture of gcc and cc. The effect on external functions which return stuructures is uncertain. According to the Eiffel environment manual section 25.4, Eiffel expects such functions to behave in the classic cc way. Whether the generated C which calls the function is declared as receiving a pointer or a structure I do not know. -fwritable-strings Gcc compiles string constants into the text area (read only). This causes the "OnceStr" function in _basic.c to fail since it puts Eiffel string header stuff in the first 8 bytes of the string (the C version of the string has 8 leading asterisks). This flag tells gcc to behave in the standard way. If you do use gcc on your site, beware the dangers of mixed compilation. I THINK the only way this will bite is in the structure return problem described above (which only occurs when getting an expanded class or "BITS M" type back anyway). Remember that Eiffel ".E" directories and the .o files in them are shared between all users, so if there are any other problems or if you want to dispense with the -fpcc-struct-return flag, then everyone on your installation will have to use the same C compiler all the time. For the record, we are using gcc version 1.35. My query is: do any of the items in -traditional matter, or can we dispense with that flag? Disclaimer: These are personal opinions. If you want to try out the ideas in this posting, you do so at your own risk. Paul Johnson UUCP: <world>!mcvax!ukc!gec-mrc!paj --------------------------------!-------------------------|------------------- GEC-Marconi Research is not | Telex: 995016 GECRES G | Tel: +44 245 73331 responsible for my opinions. | Inet: paj@uk.co.gec-mrc | Fax: +44 245 75244