Kai_Henningsen@ms.maus.de (Kai Henningsen) (04/19/91)
SC>What you describe is common in implementations of C++, but does not SC>usually apply to C. C++ allows specification of runtime code to SC>be executed (conceptually) before main(), and (conceptually) after SC>main() exits. C provides no such facility to the C programmer, and SC>it is unusual for a C compiler to require that main() be compiled by SC>that C compiler (but some have that requirement for other reasons). Not exactly. ANSI-C specifies that exit() or leaving main() will execute procedures specified via atexit(), and furthermore specifies that at that time, stdio-cleanup is performed (files closed, etc.). The latter requirement exists on every Unix-C. It's the difference between exit() and _exit(). SC>Of the C++ object-code compilers I am familiar with, all provide a SC>companion C compiler, and none have any requirement on main() that SC>would prevent mixing C and C++ code. Some C++ object-code compilers SC>do not even require main() to be written in C++. This, of course, is something quite different :-) Whether it gives you a portable program, however, is something else ... To overcome the problem, I would suggest to use some my_own_main() in both languages, and a main() which simply calls that. Then, when porting, you just modify that trivial main(), which should be simple, provided you have compiler docs. Use whichever language is more appropriate ... MfG Kai