首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

想自定义一个宏函数,但是…该怎么处理

2012-06-13 
想自定义一个宏函数,但是……C/C++ code#include iostreamusing namespace std#ifdef PI#undef PI#endif#

想自定义一个宏函数,但是……

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)

热点排行