How to get runtime args from shared static this module ctor?

Andrej Mitrovic andrej.mitrovich at gmail.com
Mon Jan 9 10:12:30 PST 2012


Sweeet, thanks Joshua!

On 1/9/12, Joshua Reusch <yoschi at arkandos.de> wrote:
> Am 09.01.2012 18:00, schrieb Andrej Mitrovic:
>> I need to get the name of the executable but without using a string[]
>> from main. I'm wrapping a 3rd party library that requires me to
>> initialize it by calling an extern function to pass the executable
>> name.
>>
>> However I don't want to force the user to pass args from main when
>> constructing a class, so I was wondering if there's a cross-platform
>> way of getting the arguments which I could use in a shared static this
>> module constructor inside of my wrapper library?
>>
>> Druntime probably has the arguments stored somewhere upon app entry
>> (before calling my main function). Is there a way to extract them?
>> Otherwise I'll have to use OS-specific APIs, but I'd rather avoid
>> those. Worst-case-scenario I'll just have to make passing args[] from
>> main a requirement of the library. It's not a big issue, but slightly
>> annoying.
>
> They are stored in Runtime.args (you must import core.runtime).
>
> Joshua
>


More information about the Digitalmars-d-learn mailing list