View Full Version : wglGetProcAddress compilation errors...

07-03-2002, 02:41 AM
Hi, I'm having some problems compiling my code using wglGetProcAddress...
I'm using VC++ 6 SP5 on Win2k for reference.
Whenever I assign the function pointer, it gives me an error:
error C2440: '=' : cannot convert from 'int (__stdcall *)(void)' to 'void (__stdcall *)(unsigned int,float)

I get similar (the parameters vary with the GL call I'm assigning) errors for EVERY assignment I do (loading each OpenGL function from the library).

Now, this is with the file haivng a .cpp extension, if I change it to a .c extension, the compiler just gives a warning (number #4113 I think) and carries on happily.
While I'd like to say it's a solution just to have it as a .c file, I'd like to know if anybody else has encountered such a problem and what can be done to resolve it short of changing the file extension.

Thanks for any help,


07-03-2002, 04:32 AM
Sounds like you are trying to cast to the wrong function pointer types, or possibly are not casting at all.

Here's an example of how it should be used..

// This line is from glext.h
typedef void (APIENTRY * PFNGLFOGCOORDFEXTPROC) (GLfloat coord);


glFogCoordfEXT = (PFNGLFOGCOORDFEXTPROC)wglGetProcAddress("glFogCoordfEXT");

// then just use like a function

Hope that helps.

[This message has been edited by Deiussum (edited 07-03-2002).]

07-03-2002, 06:06 AM
Thanks Deiussum - I wasn't casting at all http://www.opengl.org/discussion_boards/ubb/smile.gif

That was partly because I hadn't typedef'd the function pointers but anyway...

I've re-organised everything and am casting like you said, it works OK now.

Thankyou again.