Browse Source

Define WIN32_LEAN_AND_MEAN globally

In modern Windows code WIN32_LEAN_AND_MEAN should be defined.

Without this define windows.h pulls in some legacy headers, notably
winsocks.h. Modern code that cares about winsocks includes winsocks2.h
which conflicts with winsocks.h. Other code that does not care about
winsocks (OpenGL, fontconfig, ...) includes windows.h pulling in legacy
winsocks.h, causing definition conflicts and build errors.

At worst defining WIN32_LEAN_AND_MEAN requires explicitly including some
additional headers on Windows.
pull/18/head
Michal Suchanek 5 months ago
committed by Mark Roszko
parent
commit
81bbb5e67b
  1. 1
      3d-viewer/common_ogl/openGL_includes.h
  2. 9
      CMakeLists.txt
  3. 1
      common/dialogs/panel_printer_list.cpp
  4. 1
      common/font/fontconfig.cpp
  5. 1
      libs/core/profile.cpp

1
3d-viewer/common_ogl/openGL_includes.h

@ -42,7 +42,6 @@
#ifdef _WIN32
// required for the windows gl.h to work
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif

9
CMakeLists.txt

@ -62,6 +62,15 @@ set( CMAKE_MODULE_PATH "${KICAD_CMAKE_MODULE_PATH}" )
include( ConfigurePlatform )
if( WIN32 )
# Without WIN32_LEAN_AND_MEAN defined including windows.h pulls in legacy
# winsocks.h which conflicts with winsocks2.h used by modern libraries such
# as curl.
# There is no harm in defining this globally, at worst some additional
# headers have to be included explicitly.
add_compile_definitions( WIN32_LEAN_AND_MEAN )
endif()
# Create a flag to identify the non-Apple unix systems
if( UNIX AND NOT APPLE )
set( UNIX_NOT_APPLE ON )

1
common/dialogs/panel_printer_list.cpp

@ -29,6 +29,7 @@
#ifdef __WXMSW__
#include <windows.h>
#include <winspool.h>
#elif defined( CUPS_LIST_PRINTERS )
#include <cups/cups.h>
#endif

1
common/font/fontconfig.cpp

@ -30,7 +30,6 @@
#include <embedded_files.h>
#ifdef __WIN32__
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif

1
libs/core/profile.cpp

@ -28,7 +28,6 @@
#if defined( _WIN32 )
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
int64_t GetRunningMicroSecs()

Loading…
Cancel
Save