PDA

View Full Version : declaration error



joey
12-09-2001, 10:27 PM
static GLfloat theta[] = {0.0, 0.0, 0.0};

Why do i get error when i declare the above???
The errors are...
error C2059: syntax error : 'static '

And also, i would like to know what's the difference between float and GLfloat??

Why is that i get errors sometimes when i declare variables as GLfloat, before my main(i.e. aft i include all my header files)???
meaning, it does not take it as a variable type(i.e int, char, float) and appear int black instead of blue...

Thanks....

mikael_aronsson
12-09-2001, 10:33 PM
Hi !

Many times errors like this has nothing to do with the line with the error code, if you have included windows.h and opengl.h before then it works, so take a look at the code before that line, often you find the problem there.

Mikael

RedZen
12-10-2001, 12:13 AM
Hmmm, it works perfectly when I try it.
And I don't see why it shouldn't.
As far as I know, GLfloat and float is exactly the same thing. I think it might be used for clarity. I often pass my rendering module straight floats and it executes perfectly.
Anyway, here's how I put it.
#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>

static GLfloat theta[] = {0.0, 0.0, 0.0};

void main(void){}

I think Mikael is correct. Focus on the line of code right before this declaration, youre error is prolly there.

kehziah
12-10-2001, 01:29 AM
always include windows.h before anything else. Includes before windows.h are kind of ignored. So if you #include <gl/gl.h> before #include <windows.h>, gl.h is not *properly* included (whatever it can mean), and GLfloat is not known by the compiler. One of the strange behaviors of VC++... I think it can be fixed in one of the 300,000 options of the compiler. If you don't want to have problems, include windows.h before the other headers.

PS : it's the same with stdafx.h when you use appwizard. You must include it before the other files.