[comp.lang.c++] Access to argc,argv outside main

dingelde@zgdvda.zgdvda.uucp (Dennis Dingeldein) (10/24/90)

Hello!

I have the following problem with my favourite language :-) :

Short:
My objects need to access argc and argv coming from the command line.
Those values are undefined outside main. So, global defined objects 
can`t access these values (Right?) .
Can I access argv, argc outside main (before entering main()) ??? How ???
These objects are part of a User Interface Toolkit, so I won`t
restrict the end user to dynamical objects or only objects inside of main,
if possible (He/She would not understand that).

Long:
I am writing objects, whose constructors creates Widgets from Motif.
When creating widgets, I like to use the resources for those widgets.
These resources can be given on the command line. So far, so good.

My objects can be defined global, that means outside main().
But there, I can not access the command line arguments. This means that
I can`t use command line given resources. I can`t even give them to
XtInitialize() (this function must be called before creating widgets,
I guess), so not even the fundamental resources (for example "-display"
or "-background") can be set.

Did anyone else had - even better solved - this problem ?
I guess that problem is not bounded to X Applications but to all
applications, where objects try to access the command arguments.

PS: excuse my english...


-- 
Dennis Dingeldein	ZGDV Zentrum fuer Graphische Datenverarbeitung
(dingelde@zgdvda.uucp)	Wilhelminenstr. 7 		    wMw
			D-6100 Darmstadt, West Germany	    ~.~
			Phone: +49/6151/155-101		    \-/

jrv@sdimax2.mitre.org (VanZandt) (10/29/90)

In article <3101@zgdvda.zgdvda.uucp> dingelde@zgdvda.zgdvda.uucp (Dennis Dingeldein) writes:
>My objects need to access argc and argv coming from the command line.
>Those values are undefined outside main. So, global defined objects 
>can`t access these values (Right?) .

Turbo C++ defines the global variables _argv and _argc which have the same
values as the variables argv and argc passed to main().  I ASSUME they are
available even before main() gets called.  (1) You might check
whether g++ implements them too.  (2) Maybe it has something equivalent.
(3) If not, how about some GNU guru adding them?

                           - Jim Van Zandt