I am now using Code::Blocks as my C++ IDE. I coded my source in Microsoft C++ Express previously and it compiled fine. When compiling the same code in Code::Blocks (using the GCC compiler) I receive this syntax error after every line a typedef or enum type is used:
Code:
error: expected primary-expression before ‘;’ token
I am using Linux instead of Windows but I believe this is irrelevant.
Here is some source code:
declarations.h
Code:
#ifndef _DECLARATIONS
#define _DECLARATIONS
typedef unsigned char byte;
typedef unsigned short uint16;
typedef unsigned long uint32;
typedef unsigned long long uint64;
#define READ_UINT16(x) (*(uint16*)(x))
#define READ_UINT32(x) (*(uint32*)(x))
#define READ_UINT64(x) (*(uint64*)(x))
#define READ_FLOAT(x) (*(float*)(x))
#endif
convert_mesh.h
Code:
#include <string>
#include <iostream>
#include <fstream>
#include "declarations.h"
using namespace::std;
class convert_mesh
{
public:
enum mesh_t { UNIT, BACKGROUND, PLAYER };
enum material_detail_t { SIMPLE, COMPLEX };
struct declaration_t {
uint32 type;
uint32 offset;
uint32 size;
};
struct index_t {
size_t index_s;
uint16 *index;
material_detail_t detail;
size_t tga_diffuse_s,
tga_normal_s,
tga_bloom_s,
tga_specular_s,
tga_lighting_s,
tga_texture_s;
string tga_diffuse,
tga_normal,
tga_bloom,
tga_specular,
tga_lighting,
tga_texture;
float dimension[9];
};
struct geometry_t {
byte no_vertices;
size_t positions_s,
uv_s,
normals_s;
float *positions,
*uv,
*normals;
};
void readMeshHeader (size_t&, byte[]);
void readMeshData (size_t&, byte[]);
void readIndexHead (size_t&, byte[], size_t);
void readIndex (size_t&, byte[], size_t);
void readMaterials (size_t&, byte[], size_t);
void readGeometryHead (size_t&, byte[], size_t);
void readPositions (size_t&, byte[], size_t);
void readUV (size_t&, byte[], size_t);
void readNormals (size_t&, byte[], size_t);
void readReference (size_t&, byte[], size_t);
void readIndexMap (size_t&, byte[], size_t);
void unknownStruct (size_t&, byte[]);
void writeColladaDAE();
private:
mesh_t mesh; // Indicates what type of mesh.
size_t declaration_s,
index_s,
geometry_s,
index_map_s;
declaration_t *declaration; // Read at the Head of the file.
index_t *index; // 16bit Index Buffer/Triangles.
geometry_t *geometry; // Positions, UV and Normals.
declaration_t *index_map; // This is for player models only.
};
#endif
convert_mesh.cpp
Code:
#include "convert_mesh.h"
void convert_mesh::readMeshHeader(size_t &cursor, byte fBuffer[])
{
uint64 signature = READ_UINT64(&fBuffer[0]);
switch (signature)
{
// A 'unit' mesh with the extension .am
case 0xA31B0061E1:
mesh = UNIT;
cursor += sizeof uint64;
break;
// A 'background' mesh with the extension .m
case 0x9BCAFE1515:
mesh = BACKGROUND;
cursor += sizeof uint64;
break;
// A 'player' mesh with the extension .wm
case 0xAF43342ABF:
mesh = PLAYER;
cursor += sizeof uint64;
break;
default:
cout << "Incorrect file type or unhandled formated." << endl;
exit(2);
break;
}
}
The lines that cause this error are the
Code:
cursor += sizeof uint64;.
It also gives the same error when using my typedefs that can be seen in declarations.h.
Thanks in advance! This one really has me stumped and I can't continue with my project