Sign in to follow this  
kibokun

OpenGL Weird gl.h syntax errors in VS2005

Recommended Posts

I searched all over for a similar problem, and most were solved by including windows.h BEFORE gl/gl.h. However, I've already done that and my errors are a bit different: 1>C:\Program Files\Microsoft Visual Studio 8\VC\include\gl/gl.h(2) : error C2146: syntax error : missing ';' before identifier 'GLUT' 1>C:\Program Files\Microsoft Visual Studio 8\VC\include\gl/gl.h(2) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>C:\Program Files\Microsoft Visual Studio 8\VC\include\gl/gl.h(2) : error C2146: syntax error : missing ';' before identifier 'version' 1>C:\Program Files\Microsoft Visual Studio 8\VC\include\gl/gl.h(2) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>C:\Program Files\Microsoft Visual Studio 8\VC\include\gl/gl.h(2) : error C2146: syntax error : missing ';' before identifier 'of' 1>C:\Program Files\Microsoft Visual Studio 8\VC\include\gl/gl.h(2) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>C:\Program Files\Microsoft Visual Studio 8\VC\include\gl/gl.h(2) : error C2143: syntax error : missing ';' before 'string' 1>C:\Program Files\Microsoft Visual Studio 8\VC\include\gl/gl.h(2) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>C:\Program Files\Microsoft Visual Studio 8\VC\include\gl/gl.h(5) : error C2143: syntax error : missing ';' before 'constant' 1>C:\Program Files\Microsoft Visual Studio 8\VC\include\gl/gl.h(5) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>C:\Program Files\Microsoft Visual Studio 8\VC\include\gl/gl.h(5) : error C2086: 'int C' : redefinition 1> C:\Program Files\Microsoft Visual Studio 8\VC\include\gl/gl.h(2) : see declaration of 'C' etc, etc. I have the headers and libs in the right place and opengl32.lib, glut32.lib, glu32.lib are linked. My include order: #include <windows.h> #include <gl/gl.h> #include <gl/glu.h> #include <gl/glaux.h> What could the problem be?

Share this post


Link to post
Share on other sites
@Brother Bob:
I'm 99.99% sure I haven't done anything dumb. However, I'll try redownloading it to see what happened.

@Nanoha:
That didn't change anything, unfortunately. :(

Share this post


Link to post
Share on other sites
Quote:
Original post by kibokun
hm, I can't seem to find a place to re-download the headers. Where are they distributed from?

If you're using Visual Studio, they probably come with it. You can usually get boilerplate stuff from khronos.org if you're desperate.

Try just opening up the file and looking to see if it contains garbage at the beginning. It really does sound like some cruft got accidentally accreted at the top of the file (perhaps while you were examining it in an editor and accidentally hiy 'save').

Share this post


Link to post
Share on other sites
Quote:
Original post by Bregma
You can usually get boilerplate stuff from khronos.org if you're desperate.

In the case of gl.h, you can only really get it from MS -- it's their own implementation of the GL, which will look different from gl.h on other platforms. Easiest thing to do is just re-download the Platform SDK.

Share this post


Link to post
Share on other sites
I suggest you get it from www.mesa.org (gl.h and glu.h) I am using myself mesa's gl.h along my own modified glu library and header (http://www.nextpoint.se/?page_id=28) . It works perfect with Visual Studio 2008.

Glaux.h should ever never be used. I think it does not even exist no more since my compiler compalines it can't be found. You must be looking at some old examples. Just delete that include statement. Glaux was an old "auxilary" library to open a gl window; you don't need it.

Further if you use glut, you don't even have to include gl.h and glu.h, glut.h automaticly includes those for you. Just include glut.h


But your problem is not bad gl.h;

It is typical error you get when you try to call some undefined functions. In past (K & R compilers) it was allowed to use functions before declaring them, and if you didn't declare them, the default return value was assumed to be integer. This is not allowed in ansi C, and that is what your compiler is telling you.

In you code - do you have anything else included before windows.h and gl headers? Such as your own written headers? Always include any own headers AFTER all standard headers.

You are right, windows.h should always be included before gl.h or glut.h.

By the way, your include statements does not list glut.h at all. How does your code looks like? Post entire example, without rendering code - just app setup.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this