Where is the error coming from?

Started by
3 comments, last by poss74 18 years, 7 months ago
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); 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.
L.I.G. == Life Is Good
Advertisement
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.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

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]
If at first you don't succeed, call it version 1.0You don't stop playing because you get old; you get old when you stop playing.
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.
L.I.G. == Life Is Good
No worries, glad to help, done it myself too many times to count [embarrass]
If at first you don't succeed, call it version 1.0You don't stop playing because you get old; you get old when you stop playing.

This topic is closed to new replies.

Advertisement