winsiderss / phnt

Native API header files for the System Informer project.
https://github.com/winsiderss/systeminformer
MIT License
991 stars 166 forks source link

Conflict with using this with winsock2 #26

Closed blaquee closed 11 months ago

blaquee commented 1 year ago

For a project of mine I am using phnt and also winsock but for some reason I am getting an ambiguous symbol error during compilation due to in_addr and I noticed that this symbol is also defined in ntrtl, is there some way to work around this? I've tried everything from including winsock2 first and completely removing it (but then I would be missing the necessary symbols and functions I need).

https://github.com/processhacker/phnt/blob/master/ntrtl.h#L5383

blaquee commented 1 year ago

The exact (and not so useful) message from Visual Studio is

Severity    Code    Description Project File    Line    Suppression State
Error   C2872   'in_addr': ambiguous symbol 
dmex commented 1 year ago

Winsock headers need to be included with a specific order:

#include <winsock2.h>
#include <ws2tcpip.h>
#include <ws2def.h>
#include <windns.h>
#include <nldef.h>
#include <iphlpapi.h>
#include <mstcpip.h>
#include <icmpapi.h>