Using a C function with command line parameters
Jacob Carlborg
doob at me.com
Mon Jul 4 09:51:48 PDT 2011
On 2011-07-04 16:31, Jonathan Sternberg wrote:
> glut has the function:
>
> void glutInit( int* pargc, char** argv );
>
> In order to use it. Since D has an ABI compatible with C, I should be able to
> write a D file with extern (C) on the glut functions. How would I wrap this
> function to be used with D arrays? Such as:
>
> int main(string[] args)
> {
> glutInit( /* I don't know what to do here */ );
> return 0;
> }
>
> Thanks.
It depends on what your needs are. If your not actually using the
arguments then you can pass in 0 and null, or 1 and the name of the
application.
As an alternative, most platforms have an API for getting the arguments
passed to an application.
Mac OS X: extern (C) char*** _NSGetEnviron();
Posix: extern (C) extern char** environ;
Don't know about Windows.
--
/Jacob Carlborg
More information about the Digitalmars-d-learn
mailing list