Reputation: 19692
I have this simple code
#include <stdio.h>
#include <OpenGL/glext.h>
#include <OpenGL/gl.h>
int main (int argc, const char * argv[])
{
printf("Hello, World!\n");
return 0;
}
If I comment out the line with "glext.h" it compiles and runs fine in xcode 4 if I uncomment that line I get 345 errors most of them 'expected * before *' ... What is going on?! both gl.h and glext.h are inside the OpenGL framework but no matter if I incluhe it or not I get the same error. I tried GCC 4.2 as well as LLVM GCC 4.2 and LLVM (in this case 21 semantic and parse errors).
I am sure my lack of experience with C is causing this but I am surprised gl.h has no problem but glext.h has.
Even if I try to compile in from the command line by gcc I get lots of
/System/Library/Frameworks/OpenGL.framework/Headers/glext.h:3137: error: expected ‘)’ before ‘const’
Any ideas?
Upvotes: 3
Views: 914
Reputation: 400334
It's a bug with glext.h
. If you look at that file, you'll see that it has a bunch of definitions that use GLenum
, but GLenum
isn't defined anywhere in that file. So, before you include glext.h
, you need to include a file that defines GLenum
. The easiest thing to do is to include gl.h
first instead of second:
#include <stdio.h>
#include <OpenGL/gl.h>
#include <OpenGL/glext.h>
Upvotes: 3
Reputation: 16240
Switch these two lines around:
#include <OpenGL/glext.h>
#include <OpenGL/gl.h>
And it should work.
Upvotes: 2