skaslev / gl3w

Simple OpenGL core profile loading
http://github.com/skaslev/gl3w
The Unlicense
705 stars 157 forks source link

Error in compilation "invalid conversion from "void(*)()" to "void*" " #11

Closed Highstaker closed 11 years ago

Highstaker commented 11 years ago

It is line 80

in function static void get_proc(const char proc)

res = glXGetProcAddress((const GLubyte *) proc); <-- this causes error

replacing with res = (void )glXGetProcAddress((const GLubyte ) proc); solves the problem

I use g++ though, maybe other compilers think it is fine and let it go

Kos commented 11 years ago

Hmm, I remember seeing that. This is a problem but it should be solved otherwise.

It isn't allowed to cast between pointers to objects and pointers to functions. res (and get_proc and gl3wGetProcAddress as well) should all have type void(*)() instead of void*. Note that glXGetProcAddress and wglGetProcAddress all return function pointers, not object pointers.

While some compilers and platforms allow such casting, it can lead to funny crashes. See also StackOverflow: C function pointer casting to void pointer.

Kos commented 11 years ago

Issued https://github.com/skaslev/gl3w/pull/12

Highstaker commented 11 years ago

good to know.

closing this one due to solution in issue #12