Summary: Expose "cArgs" in druntime
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: druntime

--- Comment #0 from Andrej Mitrovic <> 2012-08-12 
14:22:34 PDT ---
When interfacing with C/C++ libraries one common problem is having to extract
argc/argv arguments from D main() and passing them back to library functions. A
common solution is:

// Array of pointers to command line parameters.
char*[] argv =!((a)=>(a.dup~'\0').ptr).array;

But it would be much simpler (and more efficient) if argc & argv were stored
somewhere in druntime. There's a Runtime.args() function in core.runtime which
exports the runtime args as a D-friendly array, so we could provide a cArgs
equivalent which returns a struct with argc/argv.

druntime/src/rt/dmain2.d is where main is called from:
extern (C) int main(int argc, char** argv) { ... }

>From there we could easily store argc+argv into a global struct variable,
similar to how _d_args is exposed as a __gshared string[].

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to