How to check if function is declared in global scope at compile time

Viewed 1983

Let I have a header, for example #include <GL/gl.h>. It contains subset of OpenGL API functions. I need something like this:

static_assert(has_glDrawArraysIndirect::value, "There is no glDrawArraysIndirect");

Or even better:

PFNGLDRAWARRAYSINSTANCEDPROC ptr_glDrawArraysIndirect = ptr_to_glDrawArraysIndirect::ptr;

Where ptr_to_glDrawArraysIndirect::ptr unrolls to pointer to glDrawArraysIndirect if it's defined or to a stub function stub_glDrawArraysIndirect otherwise.

My target operating system is very specific. Any linker based solution (like GetProcAddress or dlsym) doesn't work for me, since there is no dynamic linker. More than, my driver doesn't provide glXGetProcAdrress nor wglGetProcAddress, basically there there is no way to query pointer at run time by function name (Actually, I want to implement such a mechanism).

Any ideas?

4 Answers
Related