How to get runtime args from shared static this module ctor?
yoschi at arkandos.de
Mon Jan 9 09:39:00 PST 2012
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
> 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
They are stored in Runtime.args (you must import core.runtime).
More information about the Digitalmars-d-learn