On 7/6/06, Iain Buchanan <[EMAIL PROTECTED]> wrote:
yes I would, except that I'm editing a class which is inherited by a
multitude of programs, so the /proc way I only have to change one file,
whereas the argv[0] way I have to change every source file...

No, that's the point of a global.  Inheritance and all doesn't matter.

You change main.c (2 lines):
char* progname = 0;
...
   progname = argv[0];

main.h (1 line):
extern char* progname;

and the source file where you want to use it it (2 lines):
#include "main.h"
...
   printf("progname is %s\n", progname);

Your details might vary, for example if there is already a globals.h
you could move the declaration from main.h to there, etc.  But this
really is the sane way of doing this...

-Richard
--
gentoo-user@gentoo.org mailing list

Reply via email to