entry at other than main (was: want to know)

der Mouse mouse at mcgill-vision.UUCP
Sat Sep 16 13:35:32 AEST 1989


In article <21897 at cup.portal.com>, Tim_CDC_Roberts at cup.portal.com writes:
> Let me give an example of a case where "main" as main program
> possibly makes an inconvenience.

> Take Control Data (...please).  On our systems, after compiling and
> linking a set of object routines, you end out with an executable
> file.  This executable can then be placed into a LIBRARY with many
> other executables.  If all the executables have the same entry point
> name (main or crt0 or _start_up or whatever), how do you designate
> which executable in the current library you wish to invoke?

> I'm not advocating changing C.  Our scheme was developed when FORTRAN
> (PROGRAM ABCD1), COBOL (ID DIVISION...PROGRAM-NAME IS ABCD2.), and
> even Pascal (PROGRAM ABCD3;) were popular.  But adding C to the list
> does require some rethinking.

main() is a specification of how the *C source code* specifies the main
entry point.  It does not necessarily imply that the symbol table of
the output file (assuming there is such) contains anything bearing any
resemblance to "main".  A C compiler on your CDC system would be
perfectly justified in recognizing the name "main" specially and
producing, instead of a normal symbol table entry, a name derived
somehow else (the name of the source file, perhaps?) and marked as
"main entry point", the same as would be produced by FORTRAN or Pascal
for a PROGRAM, for PL/I's PROC OPTIONS(MAIN), etc.  (I don't know
whether main() is required to work if called recursively or not; if so,
the compiler would have to recognize the name "main" in certain other
contexts as well.)  All that's required is that there be no possibility
of this special symbol table entry preventing the user from writing a
routine which happens to have the same name as the source file (for
example).  Nothing insurmountable.

					der Mouse

			old: mcgill-vision!mouse
			new: mouse at larry.mcrcim.mcgill.edu



More information about the Comp.lang.c mailing list