Expected primary-expression before ‘=’ token

From Cppsyntax

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;
 }