[Issue 8544] New: Expose "cArgs" in druntime
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Aug 12 14:22:36 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8544
Summary: Expose "cArgs" in druntime
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: druntime
AssignedTo: nobody at puremagic.com
ReportedBy: andrej.mitrovich at gmail.com
--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 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 = args.map!((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: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list