]> granicus.if.org Git - curl/commitdiff
curl_setup: always define WIN32_LEAN_AND_MEAN on Windows
authorMarcel Raad <Marcel.Raad@teamviewer.com>
Mon, 10 Jul 2017 12:56:11 +0000 (14:56 +0200)
committerMarcel Raad <Marcel.Raad@teamviewer.com>
Tue, 11 Jul 2017 09:57:00 +0000 (11:57 +0200)
Make sure to always define WIN32_LEAN_AND_MEAN before including any
Windows headers to avoid pulling in unnecessary headers. This avoids
unnecessary macro clashes and compiler warnings.

Ref: https://github.com/curl/curl/issues/1562
Closes https://github.com/curl/curl/pull/1672

include/curl/system.h
lib/curl_setup.h
winbuild/MakefileBuild.vc

index 973c73ad43cf8d7eca032d8274293cd26d250d5c..e808580eb08c9900a2bf70e7b199c911cda83138 100644 (file)
 /* CURL_PULL_WS2TCPIP_H is defined above when inclusion of header file  */
 /* ws2tcpip.h is required here to properly make type definitions below. */
 #ifdef CURL_PULL_WS2TCPIP_H
-#  ifndef WIN32_LEAN_AND_MEAN
-#    define WIN32_LEAN_AND_MEAN
-#  endif
 #  include <windows.h>
 #  include <winsock2.h>
 #  include <ws2tcpip.h>
index eb4f038ddc259c125990a0623487a9d93705ae11..fc597d75dcdb4371049b4bf3307bba91805a8814 100644 (file)
 #define WIN32
 #endif
 
+#ifdef WIN32
+/*
+ * Don't include unneeded stuff in Windows headers to avoid compiler
+ * warnings and macro clashes.
+ * Make sure to define this macro before including any Windows headers.
+ */
+#  ifndef WIN32_LEAN_AND_MEAN
+#    define WIN32_LEAN_AND_MEAN
+#  endif
+#endif
+
 /*
  * Include configuration script results or hand-crafted
  * configuration file for platforms which lack config tool.
 #  if defined(_UNICODE) && !defined(UNICODE)
 #    define UNICODE
 #  endif
-#  ifndef WIN32_LEAN_AND_MEAN
-#    define WIN32_LEAN_AND_MEAN
-#  endif
 #  include <windows.h>
 #  ifdef HAVE_WINSOCK2_H
 #    include <winsock2.h>
index eb28efefdb9e3ddd05508615ae74b5306a73f149..1d8210b3dab1b1e63cf79dff7b5484bac52d42a1 100644 (file)
@@ -60,7 +60,7 @@ CFLAGS     = /I. /I../lib /I../include /nologo /W3 /GX /DWIN32 /YX /FD /c /DBUIL
 !ELSE\r
 CC_NODEBUG  = $(CC) /O2 /DNDEBUG\r
 CC_DEBUG    = $(CC) /Od /D_DEBUG /RTC1 /Z7 /LDd /W3\r
-CFLAGS      = /I. /I ../lib /I../include /nologo /W3 /EHsc /DWIN32 /FD /c /DBUILDING_LIBCURL /DWIN32_LEAN_AND_MEAN\r
+CFLAGS      = /I. /I ../lib /I../include /nologo /W3 /EHsc /DWIN32 /FD /c /DBUILDING_LIBCURL\r
 !ENDIF\r
 \r
 LFLAGS     = /nologo /machine:$(MACHINE)\r