Sign in to follow this  

Where is the error coming from?

This topic is 4491 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

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 this post


Link to post
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 this post


Link to post
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     // OR
const int MFRONT = 1;



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

Share this post


Link to post
Share on other sites

This topic is 4491 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this