• Advertisement

#### Archived

This topic is now archived and is closed to further replies.

# what is wrong with this code

This topic is 5096 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

Can anyone see why the compile keeps giving me an error. It compiled before and then I went to the computer lab and changed some of the files. When I uploaded them back to my home computer the compiler keeps saying that there is a syntax error even though the lab computers compile the same code with no complaints or warnings. The compiler I am using is Dev C++ v4.9.8.0 Here is the warning: Model.h:18: syntax error before *'' token Model.h
#ifndef _MYSUBDIVISION_H_
#define _MYSUBDIVISION_H_

#include <fstream>
#include <iostream>
#include "Vertex.h"

class Model
{
private:
int sub_level;
int levels_computed;
int num_vertices;
int num_faces;

std::string model_file;

Polygon ** faceList;  //this is the line giving the error

Vertex ** vertexList;

public:
Model();
Model(std::string);
int loadModel();
void render();
void subdivide(bool);
void create_adjacencies();

};

#endif

Vertex.h
#ifndef _MYPOLYGON_H_
#define _MYPOLYGON_H_

#include <GL/gl.h>
#include <iostream>

static const int max_neighbors=12;

class Vertex;
class Polygon;

class Vertex
{
private:
int myid;
int num_neighbors;

double x;
double y;
double z;

double * normal;

Vertex ** neighbors;

public:
Vertex();
Vertex(int, double, double, double);

inline void setId(int newid) {myid=newid;}
inline int getId() {return myid;}
inline void render();

void setPoints(double d1, double d2, double d3);
void getPoints(double *);
void getWeightedPoints(double *, double);
void addWeight(double *);
void addNeighbor(bool, Vertex *);

void getNormal(double *);
void createNormal();
void normalize();

Vertex * evenSubdivide(int);
Vertex * oddSubdivide(int, Vertex *);

};

class Polygon
{
private:
int sub_count;
int num_neighbors;

Vertex ** points;
Vertex ** sub_point;

Polygon ** neighbors;
Polygon ** children;

public:
Polygon();
Polygon(Vertex *, Vertex *, Vertex *);

bool checkNeighbor(Polygon *);

int subdivide(int, int);

void render(int, int);
void addNeighbor(Polygon *);
void getVertices(Vertex **);
void notify(Vertex *, Vertex *, Vertex *);

};

#endif
`
"Give a man a fish and he will eat for a day, drown a man in the water and the fish will eat for a week!

#### Share this post

##### Share on other sites
Advertisement
Um, because you''re not including std::string? And the computers at the lab have a version of the STL that includes <string> while including <iostream>?

When you see "Syntax error before ...", it often means a few lines before. It can take a while before the C++ parser realizes that it''s confused.

"Sneftel is correct, if rather vulgar." --Flarelocke

#### Share this post

##### Share on other sites
Are you using Dev-C++ at home and something else [eg MSVC++ at the lab]? I''ve found that ported code between the two doesn''t always co-operate. Make sure there aren''t any errors in the code that you wrote at the lab. BTW, is the compiler telling you about any other errors? Sometimes, errors like the one you describe are a result of something else.

#### Share this post

##### Share on other sites
@Sneftel
Yeah I thought about the string thing causing the compiler to barf but I have already tried commenting it out and I still get the same error

@langguy
The computers in the lab run redhat linux with gcc 3.2.2
My home computer is WinXP. Like I said before the code was
working before I went to the lab and made changes. The change
being that Polygon used to be called Face.

Update on the problem

The problem seems to be that the compiler doesnt think that Polygon has been defined even though Vertex.cpp which contains all of the function definitions for class Polygon compiles with no errors.

"Give a man a fish and he will eat for a day, drown a man in the water and the fish will eat for a week!

[edited by - cmptrgear on February 7, 2004 10:51:38 PM]

#### Share this post

##### Share on other sites
Ok so I fixed the problem by changing the name of Polygon to CPolygon. WTF is up with that?

"Give a man a fish and he will eat for a day, drown a man in the water and the fish will eat for a week!

#### Share this post

##### Share on other sites
quote:
Original post by cmptrgear
Ok so I fixed the problem by changing the name of Polygon to CPolygon. WTF is up with that?

check all the files that are included at any point for Polygon and chances are you will find some windows header with a function called Polygon. like so often when using common names there might have been some guys at ms deciding that they were using it first and the rest should just go and use another name. wingdi for example, though i wouldnt know why this should be included in a project thats also going to be used under linux.

#### Share this post

##### Share on other sites

• Advertisement