Complex C typedef decl replacement
Jacob Carlborg
doob at me.com
Fri Nov 23 06:22:10 PST 2012
On 2012-11-23 14:26, Andrey wrote:
> Hello everyone!
>
> What a proper replacement is for C declarations like this?
>
> typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target,
> GLint level, GLvoid *img);
I would guess that APIENTRYP and PFNGLGETCOMPRESSEDTEXIMAGEPROC are
macros. You first have to look up what those evaluate to. This is
probably a function pointer.
> typedef GLvoid (APIENTRY * PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const
> GLint *first, const GLsizei *count, GLsizei primcount);
Same as above.
> And this:
>
> void glAlphaFunc( GLenum func, GLclampf ref ); //ref is not acceptable
> as var name in D
Just use a difference name, like ref_, the parameter names doesn't
matter when creating bindings.
> alias void (* _GLUfuncptr)(); //how to make a proper aliasing of a
> function pointer?
A function pointer in D looks like:
void function () foo;
So to make an alias to the above function pointer, it would look like this:
extern (C) void function () _GLUfuncptr;
Take a look at DStep, a tool for automatically converting C headers to D
modules:
https://github.com/jacob-carlborg/dstep
--
/Jacob Carlborg
More information about the Digitalmars-d-learn
mailing list