c++ - "invalid pure specifier"当我的意思是没有纯说明符时?

标签 c++ g++

考虑以下代码片段:

class UltraProbe {
public:
  ConnectProbe *CP() {
    return probes.CP;  // if type == UP_CONNECT
  }
private:
  probespec mypspec; /* Filled in by the appropriate set* function */
  union {
    IPExtraProbeData IP;
    ConnectProbe *CP;
    //    ArpProbe *AP;
  } probes;

};

bool do_one_select_round(UltraScanInfo *USI, struct timeval *stime) {

  UltraProbe *probe = NULL;
  int errno = (probe->CP()->connect_result);

}

为什么我会收到以下错误?

scan_engine_connect.cc:592:22: error: invalid pure specifier (only ‘= 0’ is allowed) before ‘probe’
         int errno = (probe->CP()->connect_result);
                      ^

最佳答案

errno 是一个宏,可能会解析为函数,因此我们有如下内容:

int errno_func() = (probe->CP()->connect_result);

因此编译器将其解释为尝试声明函数。

关于c++ - "invalid pure specifier"当我的意思是没有纯说明符时?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31092543/

相关文章:

C++ 错误 : expected identifier before ‘int’

c - 在 'c' 程序中使用 gcc/g++ 在 stdc++ 中编译时出现问题

c++ - LibSerial:无法访问 SerialStream 成员函数

c++ - recv 传入 0 以检测套接字错误是否安全?

c++ - 条件运算符的值类别

c++ - GCC 和 Clang 之间的不同行为

python - OpenMP/Pybind11 : Accessing python object in for loop returns interned string error

c# - 纹理映射 - 拉伸(stretch)

c++ - 模板返回类型为 : compiler fails at derived class with pointertype as template argument (MSVC 2013) 的虚基函数

c++ - 使用模板元编程计数?