Member Avatar for xEffrego

I get a compile error on the line

while (iteration < MAX_ITERATION && sqXY <=4) {

The error is:
expected ')' before ';' token

I am pretty sure it used to work before, this problem just popped up randomly just then. Can't the while thing take 2 expressions or can't I use the && operator?

Recommended Answers

All 8 Replies

you probably missed a semicolon or bracket on another line, could you post the rest of the code (better if it's the whole code)

I might need to see the whole expression down to the semi-colon, but you might try an extra set of parentheses to help the compiler not be confused:

while ((iteration < MAX_ITERATION) && (sqXY <= 4)) { /*...*/

If that doesn't work then the problem is somewhere else (or different than you expect).

Member Avatar for xEffrego

Here is the all the code in the function:

   double px = 0;
   double py = 0;
   double newpx, newpy;
   double sqXY= 0;
   int iteration = 0;
   px = square(px) + x;
   py = square(py) + y;
   sqXY = square(px) + square(py);
   while ((iteration < MAX_ITERATION && sqXY <=4)) {
      iteration++;
      newpx = square(px) - square(py);
      newpy = 2 * px * py;
      px = newpx + x;
      py = newpy + y;
      sqXY = square(px) + square(py);
   }
Member Avatar for xEffrego

Wow....this is really weird...another one of my files is called pixelColor.c, and I have made a new one just before this compile error occured.

I left my main file unchanged for a few days, so it should work. Now there should be no way that pixelColor.c could affect my main file, as in the code above it doesn't interact at all. But I've went and reverted to an old pixelColor.c and it compiles correctly now. It is working fine now but anyone have any idea why?

If that doesn't work then the problem is somewhere else (or different than you expect).

I think thines01 is right, just the code in the function wouldn't produce the error your receiving right now, could you post now all of the code or if you don't like check every line of the program to see if you miss any semicolon or wrong use of brackets

I'd check the #define for MAX_ITERATION (or sqY if it is a macro also)

Member Avatar for majorawsome

Already posted by thines01, sorry I didn't read all of the posts

Member Avatar for xEffrego

I'd check the #define for MAX_ITERATION (or sqY if it is a macro also)

Well it you were right, my define had a ; after it....don't believe I had forgot, what an embarrasing mistake -_-

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.