C中’=’标记之前的预期表达式
虽然预处理器分配i = 3.14159265。 当我编译它时,给出一个错误说预期在’=’之前的表达式令牌是什么以及为什么?
#include #define PI = 3.14159265 int main() { float i; i = PI; printf("My first Linux program\n"); return 0; }
#define PI = 3.14159265
将PI定义为= 3.14159265
字面上包括等号。 因此i = PI;
是相同的:
i = = 3.14159265;
这显然不会编译。 要解决此问题,请从PI的定义中删除=
:
#define PI 3.14159265
使用define关键字时不需要’=’。 包括它将在定义中包含’=’。
#define PI 3.14159265