want to know

Doug Gwyn gwyn at smoke.BRL.MIL
Sat Aug 12 06:53:13 AEST 1989


In article <664 at laic.UUCP> darin at nova.UUCP (Darin Johnson) writes:
-In article <2980 at solo9.cs.vu.nl>, roemer at cs.vu.nl (Roemer Lievaart) writes:
-> I'm also a University's student in need of help. I always see that people
-> define the function 'main' in C-programs. Why is that? What should it return?
-> Can't I use another name?
-It is a UNIX-ism.  The UNIX linker uses that function name as the name of
-the first routine to jump to (although many UNIX version may have ways
-around this).  Other operating systems and linkers do things differently
-(first function found, special symbol in the object file, specified on
-command line, etc.).  However, most C compilers use main() as the
-default (with a way out if you need to), since that is what K&R uses.

The special role of main() is NOT a "UNIXism".  It is REQUIRED BEHAVIOR
in ANY standard-conforming hosted implementation of C.

Standalone use of C can indeed have other startup rules.



More information about the Comp.lang.c mailing list