I'm no C expert by any means, but I've been perusing the source tree
lately to see what I can learn. I see quite a few references to the
following variable declaration:
extern char *__progname;
I couldn't find it in any .h file (which, in my limited experience, is
where I would *think* it should be). Anyway, I poked around with nm in
/usr/lib/*.o and found it in crt0.o -- I guess the C runtime stub?
I've never seen this on any other OS, and I was wondering if someone
could at least head me in the right direction. Is this a question about
how the C library is implemented on OBSD? Or is it a question about how
gcc is configured? Any help or insight appreciated. Here's a simple
example of some code that might use something like this:
I think this is cool. Please, let's take this off list if not in anyway
appropriate -- or I can bug off.
#include <stdio.h>
extern char *__progname;
void
usage ()
{
(void) fprintf (stderr, "Usage: %s\n", __progname);
exit (1);
}
int
main (int argc, char *argv[])
{
usage ();
return 0;
}
--
"Well, if you can't believe what you read in a comic book, what *___can*
you believe?!"
-- Bullwinkle J. Moose [Jay Ward]
|