| PLEX86 | ||
|
LineEndings.c 3022LineEndings.c 3023 On Tue, 22 Feb 2005 10:57:54 +1300, Lawrence DÕOliveiro staggered into the Black Sun and said: snip further... That misses the entire point of a main() function! The main() function is the interface between the startup module (crt0.o) and your program code. It is specified not just in terms of what your program needs, but in terms of what the startup module expects when it invokes your program. The interface of course has been standardized by the ISO-ANSI C Standard, which requires that main() return a type int. First, it is not the *declaration* of main() that must return an int, it is the *definition*... and whatever it is that your program chooses to do with a main() function, the return type has nothing at all to do with whether your program wants to return a value or not. All that does count is what the function which *calls* your main() expects, and it happens that you can't change that, because it is in the startup crt module linked to your code and was written by the implementor of your system. Linux Hard Drive Question That's linux. For your purpose, you would not need ghost. You could even setup a "live" mirroring with software raid-1 making it easy to recover from a... Of course that startup code expects your main() function to return a type int, and it is entirely possible that the calling code may not even be able to execute your main() if it is not defined to return a type int! (It is possible that functions returning void and int have entirely different stack frames, which could be totally incompatible, for example.) Here is an example of actual code (from BSD) to call main(): asm ( ".section".text-";" ".global start;" "start:" "movl %ebx,psstrings;" "movl %edx,term;" "xorl %ebp,%ebp;" "jmp start" ); ... static void (*term)(void); ... void start(int argc) { struct psstrings *psp = psstrings; ... } Note that main() is the argument to the exit() function, and of course exit() *requires* an argument of type int. Because of that, the stack frame that is setup for main() *must* be compatible with the requirements of exit(), or main() might not even be executed! It isn't optional. --
|
||||
Linux groups from Newsgroups The #1 Usenet Provider on the Internet
|
||||