Talk:Example/OpenGL Error Testing with Message Callbacks
I was following this page to set up a message callback. After my callback returned for the first time, the stack would always be busted and the program would crash soon after. It took me a while to figure out that this was caused by incompatible calling conventions. In the declaration of GLDEBUGPROC, GLAPIENTRY is used. Declaring my callback with this solves the crash.
In my Windows environment, __cdecl is the default calling convention, and GLAPIENTRY will expand to __stdcall. It compiles on my Mac too, but as it does not support KHR_debug, I cannot test its correctness. I think the incomplete declaration is also why the original author had to cast the function pointer, it works without the cast on my machines when using GLAPIENTRY.
I hope this compiles on all platforms. If someone knows of a more correct (cross platform) way to do this, be sure to edit the page. I'm interested.