Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!cs.utexas.edu!uunet!mcsun!sunic!sics.se!uplog!uplog.uplog.se!thomas From: thomas@uplog.se (Thomas Hameenaho) Newsgroups: comp.lang.c Subject: Re: want to know Message-ID: Date: 25 Aug 89 08:52:43 GMT References: <8487@bsu-cs.bsu.edu> <2980@solo9.cs.vu.nl> <182@sunquest.UUCP> <664@laic.UUCP> <14269@haddock.ima.isc.com> Sender: thomas@uplog.UUCP Organization: TeleLOGIC Uppsala AB Lines: 34 In-reply-to: karl@haddock.ima.isc.com's message of 11 Aug 89 18:27:46 GMT In article <14269@haddock.ima.isc.com> karl@haddock.ima.isc.com (Karl Heuer) writes: In article <664@laic.UUCP> darin@nova.UUCP (Darin Johnson) writes: >[Name deleted on purpose] 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? Text deleted. Second, it is not special-cased by the linker in any UNIX implementation I know of. Rather, there is a pre-main routine that calls main() just like a normal function. Execution begins at this pre-main routine, not because of a linker hack, but because when the `cc' command invokes `ld', it tells it the name of the entry-point label. The magic is in the driver program `cc'. Not always true either. COFF ld has the built-in rules: a) The value of the symbol specified with the -e option. b) The value of the symbol _start, if present. c) The value of the symbol main, if present. d) The value zero. In our Unix (V.2 for 68k) we are using the entry field in the COFF header. -- Real life: Thomas Hameenaho Email: thomas@uplog.se Snail mail: TeleLOGIC Uppsala AB Phone: +46 18 189406 Box 1218 Fax: +46 18 132039 S - 751 42 Uppsala, Sweden