digitalmars.D.learn - How to get runtime args from shared static this module ctor?
- Andrej Mitrovic (14/14) Jan 09 2012 I need to get the name of the executable but without using a string[]
- Joshua Reusch (3/17) Jan 09 2012 They are stored in Runtime.args (you must import core.runtime).
- Andrej Mitrovic (2/21) Jan 09 2012
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.
Jan 09 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 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
Jan 09 2012
Sweeet, thanks Joshua! On 1/9/12, Joshua Reusch <yoschi 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
Jan 09 2012