【问题标题】:missing binary operator before token "("标记“(”之前缺少二元运算符
【发布时间】:2012-02-19 16:04:35
【问题描述】:

错误:

cxx.cpp:5:13: error: missing binary operator before token "("
cxx.cpp:7:15: error: missing binary operator before token "("

代码:

  #if definied(_WIN32) || definied(_WIN64) || definied(__WIN32__)
        const char * PORT = "COM1";
    #elif definied(__linux) || definied(__linux__) || definied(linux)
        const char * PORT = "dev/ttyS1";
    #else 
        const char * PORT = NULL;
    #endif

问题:

  1. 编译器正在等待新的defined() 调用?
  2. 它可以检测到任何 linux(及其变体)或 windows 版本吗?

提前致谢。

【问题讨论】:

  • 由于这不可能是您的实际代码(“定义”显然是复制粘贴的错字),因此很难回答。
  • 您在整个预处理器代码示例中都拼错了defined

标签: c++ g++ preprocessor-directive


【解决方案1】:

你拼错了defined

#if definied(_WIN32) || definied(_WIN64) || definied(__WIN32__)

#elif definied(__linux) || definied(__linux__) || definied(linux)

应该是:

#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__)

#elif defined(__linux) || defined(__linux__) || defined(linux)

【讨论】:

    猜你喜欢
    • 2022-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-29
    • 1970-01-01
    • 2017-06-27
    • 1970-01-01
    • 2021-12-24
    相关资源
    最近更新 更多