Use of undeclared identifier 'inet_pton'
-
I have wrote a server app in C++ using low-level windows networking API's, I'm shifted to QT to make GUI for my app. The problem i'm getting is; the QT build environment doesn't recognize inet_pton API because i'm able to build and run the project smoothly in VS19.
I've already included the required header file i.e. ws2tcpip.h and have linked it with the corresponding library Ws2_32.lib using pragma.
I'm not familiar with the QT Build environment so any help would be appreciated.
-
As stated in your link the minimum required windows version is
Minimum supported client Windows 8.1, Windows Vista [desktop apps | UWP apps]
So you have to define WIN32_WINNT appropriately
-
To which version? And where exactly? You normally don't define it in a source file but as global compiler define when you compile your app/library.
-
@Christian-Ehrlicher I tried to define it in my .cpp file as
#define _WIN32_WINNT_WIN8 0x0602
But the QT Creator warned me that '_WIN32_WINNT macro redefinition'
I think VS automatically adds it but QT doesn't. where should i place it ?
-
As stated in the documentation you gave us, you have to set _WIN32_WINNT to a value greater or equal to Windows 8 and you must not redefine a value defined by the windows headers itself. When you use qmake you can add a compiler definitions with the
DEFINE
command: https://doc.qt.io/qt-5.12/qmake-variable-reference.html#definesDEFINES += _WIN32_WINNT=0x0602
But since we're here in Qt-forum - why not use QHostAdress?