VC++.NET

M

Michael Sgier

Hi
i trying to port my OpenGL / C++ / SDL project to VC++.NET.
Why do i get those errors. The code compiles under Linux without
problems. I beliebe to have set correctly
the include and lib dirs also the headers.
Those errors do NOT make any sense at all.
THANKS and regards
Michael

warning C4067: unexpected tokens following preprocessor directive -
expected a newline
fatal error C1070: mismatched #if/#endif pair in file 'f:\aura\src\world.h'

warning C4067: unexpected tokens following preprocessor directive -
expected a newline
fatal error C1070: mismatched #if/#endif pair in file 'f:\aura\src\world.h'
error C2144: syntax error : 'void' should be preceded by ';'

followed by thousand errors in gl.h
 
Z

Zara

Hi
i trying to port my OpenGL / C++ / SDL project to VC++.NET.
Why do i get those errors. The code compiles under Linux without
problems. I beliebe to have set correctly
the include and lib dirs also the headers.
Those errors do NOT make any sense at all.
THANKS and regards
Michael

warning C4067: unexpected tokens following preprocessor directive -
expected a newline
fatal error C1070: mismatched #if/#endif pair in file 'f:\aura\src\world.h'

warning C4067: unexpected tokens following preprocessor directive -
expected a newline
fatal error C1070: mismatched #if/#endif pair in file 'f:\aura\src\world.h'
error C2144: syntax error : 'void' should be preceded by ';'

followed by thousand errors in gl.h

You are using something like:
#if defined(something)
#endif defined(something)

You *must* change that to:

#if defined(something)
#endif // defined(something)
 
J

John Harrison

Michael said:
Hi
i trying to port my OpenGL / C++ / SDL project to VC++.NET.
Why do i get those errors. The code compiles under Linux without
problems. I beliebe to have set correctly
the include and lib dirs also the headers.
Those errors do NOT make any sense at all.
THANKS and regards
Michael

warning C4067: unexpected tokens following preprocessor directive -
expected a newline
fatal error C1070: mismatched #if/#endif pair in file 'f:\aura\src\world.h'

warning C4067: unexpected tokens following preprocessor directive -
expected a newline
fatal error C1070: mismatched #if/#endif pair in file 'f:\aura\src\world.h'
error C2144: syntax error : 'void' should be preceded by ';'

followed by thousand errors in gl.h

It would obviously help if you quoted the lines which cause the errors.
Is this so hard to do? Normally we see code without the error messages,
you've manged to do it the other way round.

I would guess that you have an error in the preprocessing directives in
the file mentioned, but without seeing the file it is difficult to
speculate what that might be.

john
 
M

Michael Sgier

Hello John
that's the whole file nothing cut out. I checked all files as world.h
is the last header file but still i couldn't find anything. Also i tried
to switch precomiling//precompiled headers on and off...no effect. I
copied those files to another working Ogl program ( without SDL ) and
got exactly the same errors....
THANKS
Michael


#ifndef __WORLD_H
#define __WORLD_H



//#include <dmusicc.h> // DirectMusic includes

//#include <dmusici.h>

//#include <d3d8types.h> // for D3DVECTOR

//#include <cguid.h> // for GUID_NULL

#include <typeinfo> // for RTTI



#include "gui.h"

#include "player.h"

#include "sod.h"

#include "ogro.h"

#include "entity.h"

#include "Md3.h"
#include "md2.h"
#include "object.h"

#include "camera.h"

#include "terrain.h"

//#include "audiosystem.h"

#include "tree.h"



#define MAX_ENEMIES 10



class CWorld

{

private:

int numOgros, numSods;

int screenWidth, screenHeight;

bool gameDone;




protected:

void OnAnimate(float deltaTime);

void OnDraw(CCamera *camera, CTexture *tex);

void OnPrepare();



public:

//HWND hwnd;



CTerrain *terrain; // the terrain

CCamera *camera; // the camera

CPlayer *player;
//CPlayer *OnGetPlayer() { return player; }
// the player

//CAudioSystem *audioSystem; // the audio system

//CAudio *worldSound; // the world ambient sound

CGUI *gui;



COgroEnemy *ogroEnemy; // ogro enemies

CSodEnemy *sodEnemy; // sod enemies



float timeStart;

float timeElapsed;



CWorld();

CWorld(CCamera *c);

~CWorld();



// initialize terrain, load objects and put in container

void LoadWorld();

void UnloadWorld();



// int CountObjectTypes(const type_info &classID);



// do physics calculations for all objects in the world

// including collisions

// void Animate(float deltaTime, CCamera* camera, CPlayer* player);

void Animate(float deltaTime);

// render all objects in the world

void Draw(CCamera *camera);

void Prepare() { OnPrepare(); }
int DrawCube();


void FadeScreen();

void SetScreen(int width, int height);



bool IsGameDone() { return gameDone; }

void QuitGame() { gameDone = true; }

int GetOgros() { return numOgros; }

int GetSods() { return numSods; }

};





#endif
 
I

Ian

Michael said:
Hello John
that's the whole file nothing cut out. I checked all files as world.h
is the last header file but still i couldn't find anything. Also i tried
to switch precomiling//precompiled headers on and off...no effect. I
copied those files to another working Ogl program ( without SDL ) and
got exactly the same errors....
THANKS
Michael


#ifndef __WORLD_H

Avoid double underscores.

Ian
 
P

paulius-maruska

Michael said:
Nope that doesn't help. Still the same errors.
Not that long ago, i had some problems with preprocessor too. In my
case, what solved the problem is the newline after header-guard #endif.

Other than that, there could be problems in the other files that you
include (VC doesn't always report the right filename), so you might
want to check them too.
 
M

Michael Sgier

Hello
Nope no help so far...It must be some sort of alignment. I tried devCPP
and thatone only stops at several #include xxx without any details to
the errors. Really strange and timeconsuming aargh.
THANKS for further tips.
Michael
 
J

John Harrison

Michael said:
Hello John
that's the whole file nothing cut out. I checked all files as world.h
is the last header file but still i couldn't find anything. Also i tried
to switch precomiling//precompiled headers on and off...no effect. I
copied those files to another working Ogl program ( without SDL ) and
got exactly the same errors....
THANKS
Michael


#ifndef __WORLD_H
#define __WORLD_H



//#include <dmusicc.h> // DirectMusic includes

//#include <dmusici.h>

//#include <d3d8types.h> // for D3DVECTOR

//#include <cguid.h> // for GUID_NULL

#include <typeinfo> // for RTTI



#include "gui.h"

#include "player.h"

#include "sod.h"

#include "ogro.h"

#include "entity.h"

#include "Md3.h"
#include "md2.h"
#include "object.h"

#include "camera.h"

#include "terrain.h"

//#include "audiosystem.h"

#include "tree.h"



#define MAX_ENEMIES 10



class CWorld

{

private:

int numOgros, numSods;

int screenWidth, screenHeight;

bool gameDone;




protected:

void OnAnimate(float deltaTime);

void OnDraw(CCamera *camera, CTexture *tex);

void OnPrepare();



public:

//HWND hwnd;



CTerrain *terrain; // the terrain

CCamera *camera; // the camera

CPlayer *player;
//CPlayer *OnGetPlayer() { return player; }
// the player

//CAudioSystem *audioSystem; // the audio system

//CAudio *worldSound; // the world ambient sound

CGUI *gui;



COgroEnemy *ogroEnemy; // ogro enemies

CSodEnemy *sodEnemy; // sod enemies



float timeStart;

float timeElapsed;



CWorld();

CWorld(CCamera *c);

~CWorld();



// initialize terrain, load objects and put in container

void LoadWorld();

void UnloadWorld();



// int CountObjectTypes(const type_info &classID);



// do physics calculations for all objects in the world

// including collisions

// void Animate(float deltaTime, CCamera* camera, CPlayer* player);

void Animate(float deltaTime);

// render all objects in the world

void Draw(CCamera *camera);

void Prepare() { OnPrepare(); }
int DrawCube();


void FadeScreen();

void SetScreen(int width, int height);



bool IsGameDone() { return gameDone; }

void QuitGame() { gameDone = true; }

int GetOgros() { return numOgros; }

int GetSods() { return numSods; }

};





#endif

This is a strange error. Notice there are no #if/#endif pairs in that file.

I would try removing code until the error goes away. Last bit of code
removed will be the one causing the error. Start with the CWorld class
and then try each of the #includes in turn. If removing an #include
solves the problem then it's probably something in that header.

john
 
I

Ian

John said:
This is a strange error. Notice there are no #if/#endif pairs in that file.

I would try removing code until the error goes away. Last bit of code
removed will be the one causing the error. Start with the CWorld class
and then try each of the #includes in turn. If removing an #include
solves the problem then it's probably something in that header.
Could be one of the other include files has a #if and no corresponding
#endif, so the compiler only spots the problem when it runs out of input
and still has an open #if.

Ian
 
J

John Harrison

Ian said:
Could be one of the other include files has a #if and no corresponding
#endif, so the compiler only spots the problem when it runs out of input
and still has an open #if.

Ian

IIRC C++ forbids unbalanced #if/#endif or #ifdef/#endif within a single
file. So an error like that could be caught before leaving the file with
the unbalanced directives.

john
 
I

Ian

John said:
IIRC C++ forbids unbalanced #if/#endif or #ifdef/#endif within a single
file. So an error like that could be caught before leaving the file with
the unbalanced directives.
Another perennial is a missing '}' at the end of a class or namespace.

Ian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,159
Messages
2,570,881
Members
47,418
Latest member
NoellaXku

Latest Threads

Top