Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!seismo!mcnc!ece-csc!ncrcae!ncr-sd!hp-sdd!hplabs!hpcea!hpfcdc!rml
From: rml@hpfcdc.HP.COM (Bob Lenk)
Newsgroups: comp.lang.c
Subject: Re: Accessing argc & argv from a function
Message-ID: <5080002@hpfcdc.HP.COM>
Date: Fri, 17-Jul-87 17:55:40 EDT
Article-I.D.: hpfcdc.5080002
Posted: Fri Jul 17 17:55:40 1987
Date-Received: Sun, 19-Jul-87 19:36:24 EDT
References: <22@flmis06.ATT.COM>
Organization: HP Ft. Collins, Co.
Lines: 22

> If you're under UN*X, include some code
>    int     myArgc;
>    char    **myArgv;
>    char    *myEnvp;
>    myMain(argc,argv,envp)
>	int     argc;
>	char    **argv;
>	char    *envp;
>    {
>	myArgc = argc;
>	myArgv = argv;
>	return main(argc,argv,envp);
>    }
> and use the -e option of ld.  my{Arg[cv],Envp} have global scope.

This won't work in general.  On many (or most) implementations ld's
default entry point when invoked by cc is not main (or _main) but a
special machine-dependent piece of code that invokes main.  This
technique will bypass that code and cause problems.

		Bob Lenk
		{ihnp4, hplabs}!hpfcla!rml