C code working in Linux but not in Windows

hey there
i just loaded my C code i have been working on in linux into my home visual 6 studio and i cant get my code to compile
i have set up the linking properly and it finds gl.h and the definition for typedef int GLint;
but it says that ‘GLint CirclePoints = 60;’
is an illegal use of this type as an expression
if anyone could help me that would be great

I’ve never seen the like. Where is that expression located: GLint CirclePoints = 60 ?

#include <Gl\glut.h>
#include <math.h>
#define PI 3.14159
void display(void)
int i = 0;
float angle;
/* clear window */
GLint CirclePoints = 60;
if you need more info i can post the whole program…also i am a newbie at openGl so go easy :slight_smile:

I’ll bet that your header is not visible from your source file.

Don’t forget this:
#include <GL/gl.h>

hey there portal
i loaded my code onto a web page because i still cant get it working
have a look at it at www.geocities.com/bernief_1982/index.html

If the compiler is complaining about an undefined type, then you know what the problem is: it can’t see the header - it’s that simple.
GLint, and all the other basic GL types are defined in gl.h.

try this:
#include <windows.h>
#include <GL\gl.h>
#include <GL\glut.h>

the compiler is just complaining about an illegal use of the type
it finds the definition in gl.h fine but still doesnt like the code
thats the problem im having

Bernie_82, if there’s something wrong with your code, it’s not immediately obvious to me what it is. What exactly is the compiler telling you?

This is exactly what its telling me.
You can see how it finds the declaration of GLint
thats why i find it weird that it wont work

C:\main.c(13) : error C2275: ‘GLint’ : illegal use of this type as an expression

d:\program files\microsoft visual studio\vc98\include\gl\gl.h(48) : see declaration of ‘GLint’

C:\main.c(13) : error C2146: syntax error : missing ‘;’ before identifier ‘CirclePoints’

C:\main.c(13) : error C2065: ‘CirclePoints’ : undeclared identifier

Wow, it’s been a long time since I coded in C, so long that I can’t remember if you can initialize a variable in a declaration…
Am I crazy?
Try this:
GLint CirclePoints;
CirclePoints = 60;

yeah i couldnt remember that either so i tried that before…when i do change it the problem is the same in the sense that it says illegal use of GLint as an expression
this code is right in the sense that on my universities linux machines it has no trouble compiling
im just trying to get it to work at home so i can code in comfort

This is mighty puzzling! Is this a plain vc6 install, right out of the box? Did you include windows.h? Did you try this in c++?

yeah i did all that
i’ll figure it out im sure
probably something stupid along the way
thanx for the help though

In C, you’re not allowed to declare local variables anywhere except at the beginnig of a block (*). All declarations must happen first in a block.


void display(void)
    int i = 0;
    float angle;
    /* clear window */
    GLint CirclePoints = 60;


void display(void)
    int i = 0;
    float angle;
    GLint CirclePoints = 60;
    /* clear window */

(*) I don’t know what the latest C-spec (C99 I believe) says about this, but I know for sure VC6 does not support it. If it’s allowed in C99, then maybe your compiler on Linux supports it and therefore does not complain.

thanks for that but i figured it out a little while b4
too many things to remember in too many languages nowadays

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.