请考虑以下代码段:
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);
^
答案 0 :(得分:6)
errno
是一个可能被解析为函数的宏,因此我们有如下内容:
int errno_func() = (probe->CP()->connect_result);
因此,编译器会将其解释为尝试声明函数。