I think that the values for 'WIN32_WINNT' and '_WIN32_WINNT' should be protected against redefinement.
Reason: In order for MingW to prototype getaddrinfo() and freeaddrinfo() correctly (in <ws2tcpip.h>), '_WIN32_WINNT' *must* be defined as 0x0501 or higher. or/or.h blindly defines them as 0x0400. So, building with -DHAVE_GETADDRINFO needs _WIN32_WINNT to be set to 0x0501.
As of now, MingW would simply fallback to use gethostbyname(). So I think this little patch is in order:
--- ..\Git-latest\src\or\or.h Mon Jun 20 23:58:06 2011 +++ or\or.h Tue Jun 21 00:04:42 2011 @@ -23,8 +23,12 @@ #endif
#ifdef MS_WINDOWS +#ifndef WIN32_WINNT #define WIN32_WINNT 0x400 +#endif +#ifndef _WIN32_WINNT #define _WIN32_WINNT 0x400 +#endif #define WIN32_LEAN_AND_MEAN #endif
-----------------------------
What do you say?
--gv
On Mon, Jun 20, 2011 at 6:32 PM, Gisle Vanem gvanem@broadpark.nojuswrote:
I think that the values for 'WIN32_WINNT' and '_WIN32_WINNT' should be protected against redefinement. Reason: In order for MingW to prototype getaddrinfo() and freeaddrinfo() correctly (in <ws2tcpip.h>), '_WIN32_WINNT' *must* be defined as 0x0501 or higher. or/or.h blindly defines them as 0x0400. So, building with -DHAVE_GETADDRINFO needs _WIN32_WINNT to be set to 0x0501.
I'm confused about the situation here. Does "-DHAVE_GETADDRINFO" mean that you're overriding the value in orconfig.h from the command line, and presumably setting your own _WIN32_WINNT value there too?
"Nick Mathewson" nickm@alum.mit.edu wrote:
On Mon, Jun 20, 2011 at 6:32 PM, Gisle Vanem gvanem@broadpark.nojuswrote:
I think that the values for 'WIN32_WINNT' and '_WIN32_WINNT' should be protected against redefinement. Reason: In order for MingW to prototype getaddrinfo() and freeaddrinfo() correctly (in <ws2tcpip.h>), '_WIN32_WINNT' *must* be defined as 0x0501 or higher. or/or.h blindly defines them as 0x0400. So, building with -DHAVE_GETADDRINFO needs _WIN32_WINNT to be set to 0x0501.
I'm confused about the situation here. Does "-DHAVE_GETADDRINFO" mean that you're overriding the value in orconfig.h from the command line,
Yes.
and presumably setting your own _WIN32_WINNT value there too?
Yes, the "MingW way" to use and prototype some of these enhanced function is to set _WIN32_WINNT with the proper value (0x0501 in this case. On cmd-line etc). The trouble is specifically that <or/or.h> overrides that with value 0x0400.
Here are some lines from MingW's <ws2tcpip.h>
#if (_WIN32_WINNT >= 0x0501) void WSAAPI freeaddrinfo (struct addrinfo*); int WSAAPI getaddrinfo (const char*,const char*,const struct addrinfo*, struct addrinfo**); int WSAAPI getnameinfo(const struct sockaddr*,socklen_t,char*,DWORD, char*,DWORD,int); #else /* FIXME: Need WS protocol-independent API helpers. */ #endif
----------------------
--gv