在令牌之前缺少二元运算符“(”

时间:2012-02-19 16:04:35

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

错误:

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版本?
  3. 提前感谢。

1 个答案:

答案 0 :(得分:4)

你拼错了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)