BIO: Undefine UNICODE in b_addr.c to get POSIX declaration of gai_strerror()
authorRichard Levitte <levitte@openssl.org>
Tue, 10 Nov 2020 09:45:07 +0000 (10:45 +0100)
committerRichard Levitte <levitte@openssl.org>
Fri, 13 Nov 2020 08:35:31 +0000 (09:35 +0100)
When UNICODE is defined, Windows headers push for WCHAR implementations,
which aren't compatible with POSIX declarations.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/13318)

crypto/bio/b_addr.c

index 7515cf264b1a2cd84c39d779caffd1c7c829eb69..841cc58100474812fb8e590213862b87b232208a 100644 (file)
 # define _GNU_SOURCE
 #endif
 
+/*
+ * VC configurations may define UNICODE, to indicate to the C RTL that
+ * WCHAR functions are preferred.
+ * This affects functions like gai_strerror(), which is implemented as
+ * an alias macro for gai_strerrorA() (which returns a const char *) or
+ * gai_strerrorW() (which returns a const WCHAR *).  This source file
+ * assumes POSIX declarations, so prefer the non-UNICODE definitions.
+ */
+#undef UNICODE
+
 #include <assert.h>
 #include <string.h>