triumphost 120 Posting Whiz

I have roughly 500 function pointers defined in a header like so for example:

void (__stdcall *ptr_glAccum) (GLenum op, GLfloat value);
void (__stdcall *ptr_glActiveTextureARB) (GLenum texture);
void (__stdcall *ptr_glAlphaFunc) (GLenum func, GLclampf ref);
GLboolean (__stdcall *ptr_glAreTexturesResident) (GLsizei n, const GLuint *textures, GLboolean *residences);
void (__stdcall *ptr_glArrayElement) (GLint index);
void (__stdcall *ptr_glBegin) (GLenum mode);
void (__stdcall *ptr_glBindBufferARB) (GLenum target, GLuint buffer);
void (__stdcall *ptr_glBindTexture) (GLenum target, GLuint texture);
void (__stdcall *ptr_glBitmap) (GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap);
void (__stdcall *ptr_glBlendFunc) (GLenum sfactor, GLenum dfactor);
void (__stdcall *ptr_glBufferDataARB) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage);

Now the reason I did not put the typedef or did not want to was because I can assign to and use the pointers above directly. However, if I use the typedef, then I need to create a variable of said type and assign to it then use it. That just increases my code from 1000 lines to 1500+. (500 typedefs, 500 variable declarations, 500 GetProcAddress calls at minimum).

Now when I add a typedef at the beginning of each of those function pointers, my dll is 300kb and compiles in less than 5 seconds.. However, if I remove the typedef as shown above, it skyrockets to 99% cpu when compiling and outputs a 3.51MB dll all while taking 3-4 minutes to compile..

Within the DLL's def file, it shows:

ptr_wglUseFontBitmapsA @940 DATA
ptr_wglUseFontBitmapsW @941 DATA
ptr_wglUseFontOutlinesA @942 DATA
ptr_wglUseFontOutlinesW @943 DATA

But with the typedef, that "DATA" part is gone.

Any ideas what makes the typedef so special and why this behaviour without it :S?

Sample code with the typedef:

typedef void (__stdcall *ptr_glAccum) (GLenum op, GLfloat value);
ptr_glAccum optr_glAccum;

optr_glAccum GLACCUM = xGetFunctionAddress(Module, "glAccum");  //a #define for linux/windows.
optr_glAccum(....); //Call the function indirectly using the typedef'd variable.

Code without the typedef

void (__stdcall *ptr_glAccum) (GLenum op, GLfloat value);
ptr_glAccum = xGetFunctionAddress(Module, "glAccum");  //a #define for linux/windows.
ptr_glAccum(....);  //Call the function directly using the pointer.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.