Error in compilation "invalid conversion from "void(*)()" to "void*" "
Closed this issue · 3 comments
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
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.
good to know.
closing this one due to solution in issue #12