Reputation: 791
when i try to compile the following, i receive the error "Error 1 error C2143: syntax error : missing ';' before '*'". Does anyone know why am i receiving this error? What am i doing wrong here?
struct HE_edge {
HE_vert* vert; // vertex at the end of the half-edge<br>
HE_edge* pair; // oppositely oriented half-edge<br>
HE_face* face; // the incident face<br>
HE_edge* prev; // previous half-edge around the face<br>
HE_edge* next; // next half-edge around the face<br>
};
struct HE_vert {
float x, y, z; // the vertex coordinates<br>
HE_edge* edge; // one of the half-edges emanating from the vertex<br>
};
struct HE_face {
HE_edge* edge; // one of the half-edges bordering the face<br>
};
Upvotes: 1
Views: 3519
Reputation: 227608
You need to forward declare HE_vert
and HE_face
before you use them in HE_edge
.
// fwd declarations. Can use "struct" or "class" interchangeably.
struct HE_vert;
struct HE_face;
struct HE_edge { /* as before */ };
See When to use forward declaration?
Upvotes: 2
Reputation: 210
Try to declare your structs in the right order : Since HE_edge depends on HE_vert and HE_face, declare them before.
struct HE_vert;
struct HE_face;
struct HE_edge {
HE_vert* vert; // vertex at the end of the half-edge<br>
HE_edge* pair; // oppositely oriented half-edge<br>
HE_face* face; // the incident face<br>
HE_edge* prev; // previous half-edge around the face<br>
HE_edge* next; // next half-edge around the face<br>
};
struct HE_vert {
float x, y, z; // the vertex coordinates<br>
HE_edge* edge; // one of the half-edges emanating from the vertex<br>
};
struct HE_face {
HE_edge* edge; // one of the half-edges bordering the face<br>
};
Upvotes: 4
Reputation: 6515
The first declaration has no idea what HE_vert
and HE_face
is, to you need to tell the compiler what are those:
struct HE_face;
struct HE_vert;//tell compiler what are HE_vert and HE_face
struct HE_edge {
HE_vert* vert; // vertex at the end of the half-edge<br>
HE_edge* pair; // oppositely oriented half-edge<br>
HE_face* face; // the incident face<br>
HE_edge* prev; // previous half-edge around the face<br>
HE_edge* next; // next half-edge around the face<br>
};
struct HE_vert {
float x, y, z; // the vertex coordinates<br>
HE_edge* edge; // one of the half-edges emanating from the vertex<br>
};
struct HE_face {
HE_edge* edge; // one of the half-edges bordering the face<br>
};
Razvan.
Upvotes: 1
Reputation: 409482
You must declare identifiers before you use them. For structures this is simply done by e.g.
struct HE_vert;
Place that before the definition of HE_edge
.
Upvotes: 1
Reputation: 477640
You need to declare all the classes before you use their types to make pointers:
struct HE_edge;
struct HE_vert;
struct HE_face;
// your code
Upvotes: 1