Expected primary-expression before ‘=’ token

From Cppsyntax

Revision as of 19:08, 7 July 2007 by DuckySherwood (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

You can get the error message

 expected primary-expression before ‘=’ token

if you put an equals sign in a #define.... and the line that it will complain about is the line where the #define variable is used, not the line with the #define.

WRONG

 #define PI = 3.1425926  // = is incorrect
 void foo()
 {
   int i = PI;
 }

RIGHT

 #define PI 3.1425926   // ahhh, better!
 void foo()
 {
   int i = PI;
 }