想自定义一个宏函数,但是……
- C/C++ code
#include <iostream>using namespace std;#ifdef PI#undef PI#endif#define PI 3.1415926#define CIRCUM(float f) (PI*f)int main(){ float circum = CIRCUM(8.0); cout<<circum<<endl; return 0;}错误信息如下:
1> test.cpp
1>d:\work spaces\test.cpp(30): error C2010: “f”: 宏形参表中的意外
1>d:\work spaces\test.cpp(32): error C2065: “f”: 未声明的标识符
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========
***********
请问下,这是为啥啊?
[解决办法]
#define CIRCUM(f) (PI*f)