# Where is the error coming from?

## Recommended Posts

For the life of me, I have been unable the last two days to locate what I am doing wrong in the following function. The error given is C2143: missing ':' before ';'. This is on the 15th line of the function. int NumFront=0, NumBack=0, NumPlanar=0; int nClass; // cast away const cPolygon *pPoly = (cPolygon *)&Poly; int NumPoints = pPoly->GetNumPoints(); // loop through all points for (int i=0; i < NumPoints; i++) { nClass = Classify(pPoly->m_pPoints[i]); switch(nClass) { case MFRONT: NumFront++; break; case MBACK: NumBack++; break; default: NumFront++; NumBack++; NumPlanar++; break; } } // for // all points are planar if (NumPlanar == NumPoints) { return MPLANAR; } // all points are in front of plane else if (NumFront == NumPoints) { return MFRONT; } // all points are on backside of plane else if (NumBack == NumPoints) { return MBACK; } // poly is intersecting the plane else { return MCLIPPED; } Please help, if you can. I am completely at a standstill for what the problem is.

##### Share on other sites
Since i can only guess that line 15 is the first case:

What are MFRONT, MBACK? Defines? Enums? Check, if they collide with other defines that might be defined with the same name. Try to rename them. If they're enums, put them in a namespace.

##### Share on other sites
Could be how you've defined MFRONT. If it's defined as

#define MFRONT 1;

then the 15th line becomes equivalent to:

case 1;:

which will give you the error you're experiencing. You need to use either of these two:

#define MFRONT 1     // ORconst int MFRONT = 1;

Of course, I'm only guessing what the value for MFRONT is. [grin]

##### Share on other sites
That you Poss74, you hit it right on the dollar. I had #define MFRONT 1;. I knew it had to be something obvious that I was missing. Brain fart. Thanks for the help.

##### Share on other sites
No worries, glad to help, done it myself too many times to count [embarrass]

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627638
• Total Posts
2978327

• 10
• 12
• 22
• 13
• 34