c++ - Visual C++ 中弃用的命令

标签 c++ visual-studio deprecated

在项目的 Visual Studio 2013 中构建解决方案时,我注意到我收到以下引用的警告:

warning C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings src\core\JCSocket.cpp 77 1
warning C4996: 'inet_addr': Use inet_pton() or InetPton() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings src\core\JCSocket.cpp 82 1
warning C4996: 'inet_addr': Use inet_pton() or InetPton() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings src\core\JCSocket.cpp 121 1
warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings src\core\MuninNodeServer.cpp 64 1
warning C4996: 'GetVersionExW': was declared deprecated src\plugins\disk\DiskTimeMuninNodePlugin.cpp 48 1
warning C4996: 'GetVersion': was declared deprecated src\plugins\external\ConsolePipe.cpp 12 1
warning C4996: 'GetVersionExW': was declared deprecated src\plugins\PerfCounterMuninNodePlugin.cpp 56 1
warning C4996: 'GetVersionExW': was declared deprecated src\plugins\uptime\UptimeMuninNodePlugin.cpp 34 1

每当我尝试将其更改为推荐的 IntelliSense 命令时,它都会说:

IntelliSense: identifier "inet_ntop" is undefined \src\core\MuninNodeServer.cpp 64 31

最佳答案

这些错误告诉您该怎么做。微软就是这样。

gethostbyname -> getaddrinfo
inet_addr -> inet_pton
inet_ntoa -> inet_ntop

GetVersionExWGetVersion 而言,Microsoft 建议使用适当的 Version Helper Function .

关于c++ - Visual C++ 中弃用的命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26947496/

相关文章:

c++ - Linux 中奇怪的 iconv_open 行为

asp.net-mvc - 是否可以在 Visual Studio 2013 中使用 asp.net mvc 6?

java - @PostConstruct @PreDestroy

node.js - 如何更新警告已弃用

ruby-on-rails - Rails I18n 验证弃用警告

c++ - weak_ptr - 取消引用 - 如果过期则抛出

java - 将 C# 包装器与来自 Java 应用程序的 C API 一起使用时出现异常

xml - 如何修复损坏的 csproj 文件?

mysql - 隐藏SSRS表中的一行

c++ - 如何在字符串中使用指针?