Complex C typedef decl replacement

Mike Parker aldacron at gmail.com
Fri Nov 23 07:01:51 PST 2012


On Friday, 23 November 2012 at 14:22:11 UTC, Jacob Carlborg wrote:
> 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);

extern(System) alias void function(GLenum, GLint, GLvoid*) 
PFNGLGETCOMPRESSEDTEXIMAGEPROC;

extern(System) alias void function(GLenum, const(GLint)*, 
const(GLsizei)*, GLsizei) PFNGLMULTIDRAWARRAYSPROC;


>
> So to make an alias to the above function pointer, it would 
> look like this:
>
> extern (C) void function () _GLUfuncptr;
>

Should likely be extern(System), as OpenGL & GLU are 
extern(Windows) on Windows and extern(C) everywhere else.


More information about the Digitalmars-d-learn mailing list