Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!husc6!linus!philabs!micomvax!musocs!mcgill-vision!mouse From: mouse@mcgill-vision.UUCP Newsgroups: comp.lang.c Subject: Re: Accessing argc & argv from a functi Message-ID: <884@mcgill-vision.UUCP> Date: Mon, 7-Sep-87 05:51:24 EDT Article-I.D.: mcgill-v.884 Posted: Mon Sep 7 05:51:24 1987 Date-Received: Sat, 19-Sep-87 05:41:23 EDT References: <22@flmis06.ATT.COM> <28700015@ccvaxa> <853@mcgill-vision.UUCP> <185@hobbes.UUCP> Organization: McGill University, Montreal Lines: 24 [various people, >> = me] >>>> How does one get at argc and argv from a function? >>> At McGill I modified crt0 to put argc/argv/envp into globals >> Well, I took up the concept [root@hobbes.UUCP (John Plocher) in <185@hobbes.UUCP>] > Acchh - Pffft! > int argc; char **argv; > main(ac,av) { argc = ac; argv = av; .... } > foo() { if (argc != 2) usage(); } > Why hardcode crt0? What does that buy you over this? It buys you the capability of writing a routine which accesses the arguments without needing support from main(). Try explaining to your beginning C programmer why his error messages get turned into segmentation violation coredumps because he didn't put a couple of magic assignments at the beginning of main()....ie, library routine packages can access the argument vector and wrap it all up and hide it. der Mouse (mouse@mcgill-vision.uucp)