program arguments in module constructor?
Chris Nicholson-Sauls
ibisbasenji at gmail.com
Tue May 16 12:14:00 PDT 2006
Johan Granberg wrote:
> Can this bee done?
>
> //file.d
> static this()
> {
> char[][] args=getArgs();//
> someFunk(args);
> }
>
> void main(char[][] args)
> {
> runProgram();
> }
> //end of file
>
> Basically i want to access the args argument passed to main before main
> is called. I think that when we have module constructors we should bee
> able to do this (if we already can pleas tell me).
>
> (The problem i try to solve is working around the SDLmain hack to
> initialize SDL in the module constructor of my library so that when main
> is called the SDL will already bee initialized)
>
> Thanks in advance.
I'm not sure how it might be accomplished in linux, but in Windows you could use 'LPTSTR
GetCommandLineA()' to retrieve it, but it will be as 'char*' rather than 'char[][]'.
There is 'LPWSTR* CommandLineToArvW(LPCWSTR, int*)' to convert it to an argc/argv pair,
but it isn't available in ASCII mode that I know of.
-- Chris Nicholson-Sauls
More information about the Digitalmars-d
mailing list