Topic: Enhancement Q: argc, argv, _argc, _argv, __argc, __argv


Author: gpowell@adobe.com (Gary Powell)
Date: 1995/10/06
Raw View
In article <david.172.01511565@atl-intl.com>, david@atl-intl.com wrote:

> Some compilers have external symbols _argc and _argv that act
> similarly to the argc and argv typically found in main functions.
>
> Because these are useful at constructor time before main
> gets invoked, the question/request I have is whether the standard
> could be slightly modified to specify two pairs (or triplets if one
> wants to include env) of externals:
>
>    _argc,  _argv being        const equivalents of argc and argv;
> __argc, __argv being non-const.

  IMHO I think this is an implementation detail vs a language requirement.
After all when are _argc and _argv set? There are no guarentees about
constructor creation order which would require that _argc & _argv be set
when your constructors are called.

  Besides the workaround is to put your objects either on the stack or in
the heap instead of a preallocated dataspace. Or do two initializations,
once to a default state and once after parsing the command line.

    -Gary-

---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]





Author: david@atl-intl.com
Date: 1995/10/06
Raw View
>In article <david.172.01511565@atl-intl.com>, david@atl-intl.com wrote:
>
>> Some compilers have external symbols _argc and _argv that act
>> similarly to the argc and argv typically found in main functions.
>>
>> Because these are useful at constructor time before main
>> gets invoked, the question/request I have is whether the standard
>> could be slightly modified to specify two pairs (or triplets if one
>> wants to include env) of externals:
>>
>>    _argc,  _argv being        const equivalents of argc and argv;
>> __argc, __argv being non-const.


>  IMHO I think this is an implementation detail vs a language requirement.
>After all when are _argc and _argv set? There are no guarentees about
>constructor creation order which would require that _argc & _argv be set
>when your constructors are called.

Firstly, since ..arg.. variables are not even guaranteed to be defined,
it *cannot* be an implementation detail, since code using these variables
simply would not compile on a language-conformant compiler that did not
define them.

Secondly, part of what was inherent to my suggestion was that the ..arg..
values be guaranteed to be set before any constructor anywhere is called.
This is easy because the values are obtainable by the set-up code, and
the set-up code is what starts the process of file scope constructor
action.

>  Besides the workaround is to put your objects either on the stack or in
>the heap instead of a preallocated dataspace. Or do two initializations,
>once to a default state and once after parsing the command line.

Thirdly, the whole point is to be able to do things cleanly; I am
already stuck with the obvious work-arounds, which are kluges
at best and impossible at worst.

   Regards,
   David


[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]