Skip to content

Update winlean.nim, import AddrInfo from ws2tcpip.h #24828

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/windows/winlean.nim
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ type
fd_count*: cint # unsigned
fd_array*: array[0..FD_SETSIZE-1, SocketHandle]

AddrInfo* = object
AddrInfo* {.importc: "ADDRINFOA", header: "ws2tcpip.h".} = object
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ASCII structure in 2025, you joking?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ADDRINFOA is applicable to getaddrinfo. If you want ADDRINFOW, then you should use GetAddrInfoW.

Currently, the Nim standard library uses getaddrinfo, and the GetAddrInfoW function is not imported. Users may need to import it themselves.

Nim/lib/windows/winlean.nim

Lines 571 to 576 in 10c9eba

proc getaddrinfo*(nodename, servname: cstring, hints: ptr AddrInfo,
res: var ptr AddrInfo): cint {.
stdcall, importc: "getaddrinfo", dynlib: ws2dll.}
proc freeAddrInfo*(ai: ptr AddrInfo) {.
stdcall, importc: "freeaddrinfo", dynlib: ws2dll.}

ai_flags*: cint ## Input flags.
ai_family*: cint ## Address family of socket.
ai_socktype*: cint ## Socket type.
Expand Down