mas-bandwidth / netcode

Secure client/server connections over UDP
BSD 3-Clause "New" or "Revised" License
2.43k stars 191 forks source link

Remove redundant MinGW `inet_ntop` and `inet_pton`, fix `INVALID_SOCKET` tautology #122

Closed cshenton closed 8 months ago

cshenton commented 8 months ago

Remove the #ifdef __MINGW32__ implementations of inet_ntop and inet_pton.

These are already a part of mingw headers and the conflicting definition of typedef int socklen_t causes a conflict with the windows headers (which have the final argument of inet_ntop be a size_t) which prevents compilation of the library on mingw.

Cast INVALID_SOCKET to a uint32_t to avoid compilers optimizing away the uint32 to uint64 comparison. This will just truncate the bits and give us ~(uint32_t)0 which is the desired behaviour, and also suppresses the associated compiler warning.