none
'inet_addr': Use inet_pton() or InetPton() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings RRS feed

  • Question

  • Hi all, the error in the title appeared when I was trying to use inet_addr.

    I added the line below as advised by the compiler, but the eror still appears.

    #define _WINSOCK_DEPRECATED_NO_WARNINGS

    Can anyone advise on this error? Thank you!

    Tuesday, September 2, 2014 3:19 AM

Answers

  • Hi,

    Which version of visual studio do you use? Is it VS2013 with update 3?

    Based on your description, please make sure you define  _WINSOCK_DEPRECATED_NO_WARNINGS before all the include.

    Another way you may have a try is to add #include <WS2tcpip.h> and use inet_pton(AF_INET, IP, buf) to instead of inet_addr(IP).

    In addition, you can check if your properties is settings like this: Project properties -> Configuration Properties -> C/C++ -> General -> SDL checks -> No.

    May


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by MrCapybara Wednesday, September 3, 2014 12:26 AM
    Tuesday, September 2, 2014 8:39 AM

All replies

  • Hi,

    Which version of visual studio do you use? Is it VS2013 with update 3?

    Based on your description, please make sure you define  _WINSOCK_DEPRECATED_NO_WARNINGS before all the include.

    Another way you may have a try is to add #include <WS2tcpip.h> and use inet_pton(AF_INET, IP, buf) to instead of inet_addr(IP).

    In addition, you can check if your properties is settings like this: Project properties -> Configuration Properties -> C/C++ -> General -> SDL checks -> No.

    May


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by MrCapybara Wednesday, September 3, 2014 12:26 AM
    Tuesday, September 2, 2014 8:39 AM
  • Hi May,

    Yes I am using VS2013 with update 3. From what I read about inet_pton I cant seem to use it in XP and older versions of windows, so that is not really an option for me.

    As for the property settings, I tried it but it did not solve the problem.

    I solved this after defining _WINSOCK_DEPRECATED_NO_WARNINGS in the top line of stdafx.h, as advised by you. Thank you!!!

    Wednesday, September 3, 2014 12:38 AM
  • That was not the recommendation.  What you did will have the same effect this time but it is better to follow the recommendations in case you have follow up questions.
    Wednesday, September 3, 2014 3:59 AM