want to know

Thomas Hameenaho thomas at uplog.se
Fri Aug 25 18:52:43 AEST 1989


In article <14269 at haddock.ima.isc.com> karl at haddock.ima.isc.com (Karl Heuer) writes:

   In article <664 at laic.UUCP> darin at 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 at uplog.se
Snail mail:	TeleLOGIC Uppsala AB		Phone:	+46 18 189406
		Box 1218			Fax:	+46 18 132039
		S - 751 42 Uppsala, Sweden



More information about the Comp.lang.c mailing list