need help with C++typedefs (solved)

Started by
2 comments, last by -JetSirus- 17 years, 9 months ago
I am working on a game engine. in one of the header files, the compiler (MSVC 2003) does not seem to like my typedefs even though the MSVC class view does. it gives me these errors:
Quote: e:\Lobster\Lobster\lobster.h(26) : error C2236: unexpected 'struct' 'LOB_POINTI' e:\Lobster\Lobster\lobster.h(26) : error C2143: syntax error : missing ';' before '{' e:\Lobster\Lobster\lobster.h(26) : error C2447: '{' : missing function header (old-style formal list?) e:\Lobster\Lobster\lobster.h(28) : error C2501: 'LOB_POINTI' : missing storage-class or type specifiers e:\Lobster\Lobster\lobster.h(67) : error C2146: syntax error : missing ';' before identifier 'UpLeft' e:\Lobster\Lobster\lobster.h(67) : error C2501: 'LOB_RECTI::LOB_POINTI' : missing storage-class or type specifiers e:\Lobster\Lobster\lobster.h(67) : error C2501: 'LOB_RECTI::UpLeft' : missing storage-class or type specifiers e:\Lobster\Lobster\lobster.h(67) : error C2501: 'LOB_RECTI::UpRight' : missing storage-class or type specifiers e:\Lobster\Lobster\lobster.h(67) : error C2501: 'LOB_RECTI::LowLeft' : missing storage-class or type specifiers e:\Lobster\Lobster\lobster.h(67) : error C2501: 'LOB_RECTI::LowRight' : missing storage-class or type specifiers
here is the file that generates these errors:
[source lang = 'C++']
// lobster.h : global header file for lobster game engine


#pragma once

#include <tchar.h>
#include <time.h>
#include <wtypes.h>
#include <wingdi.h>
#include <GL/gl.h>
#include <stdio.h>
#include <stdlib.h>

#include "SDL.h"
#include "targa.h"

#define LOB_WIDTH 800
#define LOB_HEIGHT 600
#define UP 2
#define DOWN 1
#define NULL 0
#define TRUE 1
#define FALSE 0

typedef struct LOB_POINTI
{
	int x, y;
}LOB_POINTI;

typedef struct LOB_POINTF
{
	float x, y;
}LOB_POINTF;

typedef struct LOB_POINTU
{
	unsigned x, y;
}LOB_POINTU;

typedef struct LOB_POINTS
{
	short x, y;
}LOB_POINTS;

typedef struct LOB_VECTI
{
	int x, y, z;
} LOB_VECTI;

typedef struct LOB_VECTF
{
	float x, y, z;
}LOB_VECTF;

typedef struct LOB_VECTU
{
	unsigned x, y, z;
}LOB_VECTU;

typedef struct LOB_VECTS
{
	short x, y, z;
}LOB_VECTS;

typedef struct LOB_RECTI
{
	LOB_POINTI UpLeft, UpRight, LowLeft, LowRight;
}LOB_RECT;

typedef struct LOB_RECTF
{
	LOB_POINTF UpLeft, UpRight, LowLeft, LowRight;
}LOB_RECTF;

typedef struct LOB_RECTU
{
	LOB_POINTU UpLeft, UpRight, LowLeft, LowRight;
}LOB_RECTU;

typedef struct LOB_RECTS
{
	LOB_POINTS UpLeft, UpRight, LowLeft, LowRight;
}LOB_RECTS;

typedef struct LOB_PLANEI
{
	LOB_VECTI Upleft, UpRight, LowLeft, LowRight;
}LOB_PLANEI;

typedef struct LOB_PLANEF
{
	LOB_VECTF UpLeft, UpRight, LowLeft, LowRight;
}LOB_PLANEF;

typedef struct LOB_PLANEU
{
	LOB_VECTU UpLeft, UpRight, LowLeft, LowRight;
}LOB_PLANEU;

typedef struct LOB_PLANES
{
	LOB_VECTU UpLeft, UpRight, LowLeft, LowRight;
}LOB_PLANES;

typedef struct LOB_CUBEF
{
	LOB_PLANEF zPos, zNeg, xPos, xNeg, yPos, yNeg;
}LOB_CUBEF;

typedef struct LOB_CUBEI
{
	LOB_PLANEI zPos, zNeg, xPos, xNeg, yPos, yNeg;
}LOB_CUBEI;

typedef struct LOB_CUBEU
{
	LOB_PLANEU zPos, zNeg, xPos, xNeg, yPos, yNeg;
}LOB_CUBEU;

typedef struct LOB_CUBES
{
	LOB_PLANES zPos, zNeg, xPos, xNeg, yPos, yNeg;
}LOB_CUBES;




typedef struct LOB_KEYS
{
	SDLKey Keys;
	char IsKeyPressed;
	SDLMod Mods;
}LOB_KEYS;

typedef struct LOB_KEYSTATE
{
	LOB_KEYS now, prev;
}LOB_KEYSTATE;

typedef struct LOB_MOUSE
{
	unsigned short xPos, yPos;
	short xVel, yVel;
	char LeftButton, RightButton, MiddleButton;
}LOB_MOUSE;

typedef struct LOB_MOUSESTATE
{
	LOB_MOUSE now, prev;
}LOB_MOUSESTATE;

//To Be provided by game
void HandleKeys(LOB_KEYSTATE keystate);
void HandleMouse(LOB_MOUSESTATE mousestate, char scroll);
void update(void);
void draw(void);
void init(void);

//Not to be provided by game
void LOB_quit(void); //tells the engine to quit and deletes stuff



I cant figure this out, as this is how ive seen typedefs done in all the books ive read. could someone please help? thanks in advance. [Edited by - _mycoplasma_ on July 21, 2006 7:35:19 PM]
Advertisement
Since most of that was using 'struct' try removing the 'typedef' from it as CPP compilers don't normally require it.

EDIT: Actually I think using typedef with a struct is the old C way of doing things, I could be wrong though.
------------------This is so stupid!
The typedefs themselves are fine (if somewhat unnecessary in C++). Chances are you're missing a ; or something somewhere in your targa.h header.
I see you solved it. Out of curiosity, what was the problem?
------------------This is so stupid!

This topic is closed to new replies.

Advertisement