want to know

Doug Gwyn gwyn at smoke.BRL.MIL
Fri Aug 18 00:59:17 AEST 1989


In article <2538 at trantor.harris-atd.com> bbadger at x102c.harris-atd.com writes:
>Firstly, it is less informative to the user.  Having a fixed entry like main
>removes the possibility of a descriptive name being applied to a program.

Program users do not see the name of the main() function at all.
I don't think I've ever had a UNIX program called "main".

>It also interferes with naming conventions for files and cross-reference tools
>like ctags.  Our local ctags has been modified to substitute ``Mfoo'' for 
>the symbol ``main()'' found in file ``foo.c''.  This kind of game wouldn't
>be required if C let you choose your main program name.

It's not required anyway.  There can be only one external function named
main() among all the source files constituting a program.  Besides, you
shouldn't lay deficiencies in "ctags" at C's doorstep.

>There are lots of UNIX programs written to simulate this by 
>switching on the value of argv[0] (the name the program was invoked by --
>see vi/ex, [ec]tags for examples), but this facility could be legitimized
>by providing an entry point specification in exec().

Programs such as "vi" do NOT follow the model you suggest, and for
exec to be able to do what you propose there would have to be substantial
changes to the kernel and to the C run-time startoff module, adding
overhead to essentially every UNIX process.  I don't see that the putative
benefits could possibly justify the cost.



More information about the Comp.lang.c mailing list