[comp.lang.c++] Can I use argc and argv in a global constructor?

beshers@pipe.columbia.edu (Clifford Beshers) (12/09/88)

Is it possible to reference argc and argv in a global
constructor?  Since the constructors are called before main and
argc and argv are local to that routine, it would seem to be
impossible.  Perhaps they should be passed to _main() as well?

This isn't really a burning issue, of course, but it's puzzling.


Clifford Beshers
Columbia University Computer Science Department
beshers@sylvester.cs.columbia.edu

bright@Data-IO.COM (Walter Bright) (12/13/88)

In article <6082@columbia.edu> beshers@pipe.UUCP () writes:
>Is it possible to reference argc and argv in a global
>constructor?

It's quite possible if you're prepared to rewrite the startup code.
You rewrite it to create two globals, _argc and _argv, before the
static constructors are called.