Skip to content

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

Merged
gafferongames merged 1 commit intomas-bandwidth:mainfrom
cshenton:windows-handle-tautology
Mar 11, 2024
Merged

Remove redundant MinGW inet_ntop and inet_pton, fix INVALID_SOCKET tautology#122
gafferongames merged 1 commit intomas-bandwidth:mainfrom
cshenton:windows-handle-tautology

Conversation

@cshenton
Copy link
Copy Markdown
Contributor

@cshenton cshenton commented Mar 11, 2024

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.

@gafferongames gafferongames merged commit 2f70334 into mas-bandwidth:main Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants