# 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 on other sites
You have an odd gl.h if you have error references to line 2 and 5 in the file; those lines are comments. Are you sure you haven't touched that file?

##### Share on other sites
what hapens when you get rid of glaux?

##### 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 on other sites
I don't think gl.h should contain the string "GLUT" at all.

##### Share on other sites
hm, I can't seem to find a place to re-download the headers. Where are they distributed from?

##### Share on other sites
Quote:
 Original post by kibokunhm, 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 on other sites
Quote:
 Original post by BregmaYou 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 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.

## 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

• ### Forum Statistics

• Total Topics
627694
• Total Posts
2978672
• ### Similar Content

• Both functions are available since 3.0, and I'm currently using glMapBuffer(), which works fine.
But, I was wondering if anyone has experienced advantage in using glMapBufferRange(), which allows to specify the range of the mapped buffer. Could this be only a safety measure or does it improve performance?
Note: I'm not asking about glBufferSubData()/glBufferData. Those two are irrelevant in this case.
• By xhcao
Before using void glBindImageTexture(    GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format), does need to make sure that texture is completeness.
• By cebugdev
hi guys,
are there any books, link online or any other resources that discusses on how to build special effects such as magic, lightning, etc. in OpenGL? i mean, yeah most of them are using particles but im looking for resources specifically on how to manipulate the particles to look like an effect that can be use for games,. i did fire particle before, and I want to learn how to do the other 'magic' as well.
Like are there one book or link(cant find in google) that atleast featured how to make different particle effects in OpenGL (or DirectX)? If there is no one stop shop for it, maybe ill just look for some tips on how to make a particle engine that is flexible enough to enable me to design different effects/magic
let me know if you guys have recommendations.
Thank you in advance!
• By dud3
How do we rotate the camera around x axis 360 degrees, without having the strange effect as in my video below?
Mine behaves exactly the same way spherical coordinates would, I'm using euler angles.
Tried googling, but couldn't find a proper answer, guessing I don't know what exactly to google for, googled 'rotate 360 around x axis', got no proper answers.

References:
Code: https://pastebin.com/Hcshj3FQ
The video shows the difference between blender and my rotation:

• By Defend
I've had a Google around for this but haven't yet found some solid advice. There is a lot of "it depends", but I'm not sure on what.
My question is what's a good rule of thumb to follow when it comes to creating/using VBOs & VAOs? As in, when should I use multiple or when should I not? My understanding so far is that if I need a new VBO, then I need a new VAO. So when it comes to rendering multiple objects I can either:
* make lots of VAO/VBO pairs and flip through them to render different objects, or
* make one big VBO and jump around its memory to render different objects.
I also understand that if I need to render objects with different vertex attributes, then a new VAO is necessary in this case.
If that "it depends" really is quite variable, what's best for a beginner with OpenGL, assuming that better approaches can be learnt later with better understanding?

• 19
• 14
• 12
• 10
• 12