加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – 令牌“=”在预处理器表达式中无效

发布时间:2020-12-16 10:43:41 所属栏目:百科 来源:网络整理
导读:我有一个程序: #include iostream#define _DEBUG = 1using namespace std;int main() { #if (_DEBUG == 1) cout "hello : " endl; #endif return 0;} 编译它会给出错误: $g++ a.cppa.cpp:7:7: error: token "=" is not valid in preprocessor expressions$
我有一个程序:

#include <iostream>

#define _DEBUG = 1

using namespace std;
int main() {
        #if (_DEBUG == 1)
                cout << "hello : " <<endl;
        #endif

        return 0;
}

编译它会给出错误:

$g++ a.cpp
a.cpp:7:7: error: token "=" is not valid in preprocessor expressions
$g++ --version
g++ (MacPorts gcc46 4.6.3_8) 4.6.3

我以为==是等式条件运算符?

解决方法

我认为只是一个错字:

#define _DEBUG = 1

应该

#define _DEBUG 1

我一直这样做!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读