When building a solution in Visual Studio 2013 of a project, I noticed that I am getting warnings for the following references:
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
Whenever I try to change it to the recommended IntelliSense command, it is saying:
IntelliSense: identifier "inet_ntop" is undefined \src\core\MuninNodeServer.cpp 64 31
These errors are telling you what to do. Microsoft is nice like that.
As far as
GetVersionExW
andGetVersion
Microsoft recommends using the appropriate Version Helper Function.Visual Studio tells you this warning cause you trying to use unsecure function which means includes the body of the function
and the body can obviously contain a signed overflow and there's a prospect to get another compiling errors or perhaps its not supported in the newer library
by the way, its about how you use this function
Simply you can disable the warning by add the following line
at the top of your code
Which disable warning error code 4996 and will work fine without any problems.