如何编译具有 MIB_IPINTERFACE_ROW 结构的代码
How to compile a code with MIB_IPINTERFACE_ROW structure
我正在尝试使用 MIB_IPINTERFACE_ROW structure 编译代码。让我们在我的工作代码中包含以下 class:
class IpInterfaceRow {
private:
MIB_IPINTERFACE_ROW mib_ipinterface_row;
};
使用 Visual Studio 2015 我面临以下错误:
unknown override specifier
(C3646) 和
missing type specifier - int assumed. Note: C++ does not support default-int
(C4430)
您可以查看 here - C3646 and here - C4430。实际上,第二个更像是一个警告,我可以用 #pragma warning
关闭它,我认为这取决于第一个(因为编译器不识别 MIB_IPINTERFACE_ROW
,它会尝试给它赋值int
,因此是第二个错误)然后,我专注于第一个。
我想这可能是 headers 的问题,我 include/not 包含的顺序错误?我尝试了很多选择:
#include <netioapi.h>
、#include <iphlapi.h>
等等...
例如,从here开始,我尝试使用
#include <ws2def.h>
#include <ws2ipdef.h>
#include <iphlpapi.h>
但结果相同...如果我尝试使用 MIB_INTERFACE_TABLE. I also tried to compile the example code in GetIpInterfaceTable(),我会遇到同样的问题,其中包括
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <winsock2.h>
#include <ws2ipdef.h>
#include <iphlpapi.h>
#include <stdio.h>
#include <stdlib.h>
#pragma comment(lib, "iphlpapi.lib")
但还是一样的结果...
有人知道哪里出了问题吗?错误 C3646 对我来说意味着什么?
以下确实有效
#include <winsock2.h>
#include <windows.h>
#include <ws2ipdef.h>
#include <iphlpapi.h>
#include <stdio.h>
#include <stdlib.h>
#pragma comment(lib, "iphlpapi.lib")
在我的代码中包含了两个文件,这给了我问题:
第一个包含iphlpapi.h(然后,在ws2ipdef.h之前包含)
第二个包含netcfgx.h,包含windows.h(然后包含在winsock2.h之前)
特别注意其他 headers 即在我的情况下 netcfgx.h
可以包含一些 headers,即 windows.h
并使顺序错误
我正在尝试使用 MIB_IPINTERFACE_ROW structure 编译代码。让我们在我的工作代码中包含以下 class:
class IpInterfaceRow {
private:
MIB_IPINTERFACE_ROW mib_ipinterface_row;
};
使用 Visual Studio 2015 我面临以下错误:
unknown override specifier
(C3646) 和
missing type specifier - int assumed. Note: C++ does not support default-int
(C4430)
您可以查看 here - C3646 and here - C4430。实际上,第二个更像是一个警告,我可以用 #pragma warning
关闭它,我认为这取决于第一个(因为编译器不识别 MIB_IPINTERFACE_ROW
,它会尝试给它赋值int
,因此是第二个错误)然后,我专注于第一个。
我想这可能是 headers 的问题,我 include/not 包含的顺序错误?我尝试了很多选择:
#include <netioapi.h>
、#include <iphlapi.h>
等等...
例如,从here开始,我尝试使用
#include <ws2def.h>
#include <ws2ipdef.h>
#include <iphlpapi.h>
但结果相同...如果我尝试使用 MIB_INTERFACE_TABLE. I also tried to compile the example code in GetIpInterfaceTable(),我会遇到同样的问题,其中包括
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <winsock2.h>
#include <ws2ipdef.h>
#include <iphlpapi.h>
#include <stdio.h>
#include <stdlib.h>
#pragma comment(lib, "iphlpapi.lib")
但还是一样的结果...
有人知道哪里出了问题吗?错误 C3646 对我来说意味着什么?
以下确实有效
#include <winsock2.h>
#include <windows.h>
#include <ws2ipdef.h>
#include <iphlpapi.h>
#include <stdio.h>
#include <stdlib.h>
#pragma comment(lib, "iphlpapi.lib")
在我的代码中包含了两个文件,这给了我问题:
第一个包含iphlpapi.h(然后,在ws2ipdef.h之前包含)
第二个包含netcfgx.h,包含windows.h(然后包含在winsock2.h之前)
特别注意其他 headers 即在我的情况下 netcfgx.h
可以包含一些 headers,即 windows.h
并使顺序错误