diff --git a/CMakeLists.txt b/CMakeLists.txt index e66f12ff..2171fee6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -135,6 +135,7 @@ if (WIN32) library_win32.cpp library_win32.hpp time_win32.cpp + win32/windows.hpp win32/except.cpp win32/except.hpp win32/handle.cpp diff --git a/backtrace_stackwalk.cpp b/backtrace_stackwalk.cpp index a9632149..ce87f6b9 100644 --- a/backtrace_stackwalk.cpp +++ b/backtrace_stackwalk.cpp @@ -11,8 +11,8 @@ #include "debug.hpp" #include "types.hpp" #include "win32/except.hpp" +#include "win32/windows.hpp" -#include #include #include diff --git a/backtrace_win32.cpp b/backtrace_win32.cpp index 4d154060..7e04a702 100644 --- a/backtrace_win32.cpp +++ b/backtrace_win32.cpp @@ -11,11 +11,11 @@ #include "win32/error.hpp" #include "win32/handle.hpp" +#include "win32/windows.hpp" #include "debug.hpp" #include "except.hpp" #include -#include #include diff --git a/debug_win32.cpp b/debug_win32.cpp index 63ffc4f5..825bba69 100644 --- a/debug_win32.cpp +++ b/debug_win32.cpp @@ -10,8 +10,8 @@ #include "log.hpp" #include "win32/except.hpp" +#include "win32/windows.hpp" -#include #include diff --git a/exe_win32.cpp b/exe_win32.cpp index 3cbd9c2d..bb8609cb 100644 --- a/exe_win32.cpp +++ b/exe_win32.cpp @@ -9,10 +9,10 @@ #include "exe.hpp" #include "win32/except.hpp" +#include "win32/windows.hpp" #include #include -#include /////////////////////////////////////////////////////////////////////////////// diff --git a/io.hpp b/io.hpp index 5246b668..ddc03151 100644 --- a/io.hpp +++ b/io.hpp @@ -20,7 +20,7 @@ #include #ifdef PLATFORM_WIN32 -#include +#include "win32/windows.hpp" #else #define O_BINARY 0 #endif diff --git a/io_win32.cpp b/io_win32.cpp index 697cf0bd..58402d8b 100644 --- a/io_win32.cpp +++ b/io_win32.cpp @@ -10,8 +10,7 @@ #include "debug.hpp" #include "win32/except.hpp" - -#include +#include "win32/windows.hpp" using cruft::detail::win32::mapped_file; diff --git a/io_win32.hpp b/io_win32.hpp index 17fcef02..a5898c38 100644 --- a/io_win32.hpp +++ b/io_win32.hpp @@ -13,11 +13,11 @@ #include "pointer.hpp" #include "io.hpp" #include "win32/handle.hpp" +#include "win32/windows.hpp" #include "view.hpp" #include #include -#include #include #include #include diff --git a/library_win32.hpp b/library_win32.hpp index 0d01a49a..6f0d4367 100644 --- a/library_win32.hpp +++ b/library_win32.hpp @@ -9,9 +9,9 @@ #ifndef __UTIL_LIBRARY_WIN32_HPP #define __UTIL_LIBRARY_WIN32_HPP -#include +#include "win32/windows.hpp" -#include +#include #include diff --git a/thread/semaphore_win32.cpp b/thread/semaphore_win32.cpp index 9e829aae..9f354228 100644 --- a/thread/semaphore_win32.cpp +++ b/thread/semaphore_win32.cpp @@ -9,11 +9,10 @@ #include "semaphore_win32.hpp" #include "../win32/except.hpp" +#include "../win32/windows.hpp" #include "../debug.hpp" -#include - using cruft::thread::semaphore; diff --git a/win32/except.hpp b/win32/except.hpp index dde8ead2..6e9a5e8e 100644 --- a/win32/except.hpp +++ b/win32/except.hpp @@ -10,10 +10,11 @@ #ifndef CRUFT_UTIL_WIN32_EXCEPT_HPP #define CRUFT_UTIL_WIN32_EXCEPT_HPP +#include "windows.hpp" + #include #include -#include namespace cruft::win32 { class error : public std::runtime_error { diff --git a/win32/handle.hpp b/win32/handle.hpp index 4fc6741e..30099a24 100644 --- a/win32/handle.hpp +++ b/win32/handle.hpp @@ -6,7 +6,7 @@ * Copyright 2016 Danny Robson */ -#include +#include "windows.hpp" #include "../posix/fd.hpp" diff --git a/win32/registry.hpp b/win32/registry.hpp index 10d47f57..bcd3bb88 100644 --- a/win32/registry.hpp +++ b/win32/registry.hpp @@ -9,9 +9,9 @@ #ifndef __UTIL_WIN32_REGISTRY_HPP #define __UTIL_WIN32_REGISTRY_HPP -#include "../view.hpp" +#include "windows.hpp" -#include +#include "../view.hpp" #include #include diff --git a/win32/windows.hpp b/win32/windows.hpp new file mode 100644 index 00000000..2395168d --- /dev/null +++ b/win32/windows.hpp @@ -0,0 +1,31 @@ +#pragma once + +// include the windows.h header in a way that won't break anything that isn't +// aware of microsoft's propensity to grab large swathes of common terms. +#if defined(_WINDOWS_) +#error "windows headers have already been included" +#endif + +#define WIN32_LEAN_AND_MEAN +#include + +// undefine a bunch of conflicting names. +#if defined(near) +#undef near +#endif + +#if defined(far) +#undef far +#endif + +#if defined(NEAR) +#undef NEAR +#endif + +#if defined(FAR) +#undef FAR +#endif + +#if defined(OPAQUE) +#undef OPAQUE +#endif \ No newline at end of file