“无效的纯说明符”,当我的意思是没有纯粹的说明符时?

时间:2015-06-27 19:11:06

标签: 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);
                      ^

1 个答案:

答案 0 :(得分:6)

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

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

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