From 5aefb2f82ae69204955fbbcb8ecc980d0db7dfe9 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Mon, 4 Mar 2019 11:25:53 +1100 Subject: [PATCH] win32/windows: undef ERROR --- win32/windows.hpp | 126 +++++++++++++++++++++++----------------------- 1 file changed, 64 insertions(+), 62 deletions(-) diff --git a/win32/windows.hpp b/win32/windows.hpp index 8d37cbba..fc0706f3 100644 --- a/win32/windows.hpp +++ b/win32/windows.hpp @@ -1,62 +1,64 @@ -#pragma once - -#include "../platform.hpp" - -// Include various useful Windows headers in a way that won't break anything -// that isn't aware of Microsoft's propensity to define away large swathes of -// frequently used symbols. - -#if defined(_WINDOWS_) -#error "windows headers have already been included" -#endif - -// Based off the approach outlined at: -// https://aras-p.info/blog/2018/01/12/Minimizing-windows.h/ - - -// Predefine the hardware platform macros that the headers will expect. -#if defined(PROCESSOR_AMD64) - #if !defined(_AMD64_) - #define _AMD64_ - #endif -#elif defined(PROCESSOR_X86) - #if !defined(_X86_) - #define _X86_ - #endif -#elif defined(PROCESSOR_ARM) - #if !defined(_ARM_) - #define _ARM_ - #endif -#else - #error "Unsupported processr" -#endif - - -// Request a smaller header. It probably won't help too much, but it shouldn't -// hurt us either. -#define WIN32_LEAN_AND_MEAN -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -// GDI isn't used in many locations but it's easier to include it hear and -// undefine various pieces of trash than let unsuspecting code get trampled -// later. -#include - -#undef near -#undef far -#undef NEAR -#undef FAR - -#undef TRANSPARENT -#undef OPAQUE - +#pragma once + +#include "../platform.hpp" + +// Include various useful Windows headers in a way that won't break anything +// that isn't aware of Microsoft's propensity to define away large swathes of +// frequently used symbols. + +#if defined(_WINDOWS_) +#error "windows headers have already been included" +#endif + +// Based off the approach outlined at: +// https://aras-p.info/blog/2018/01/12/Minimizing-windows.h/ + + +// Predefine the hardware platform macros that the headers will expect. +#if defined(PROCESSOR_AMD64) + #if !defined(_AMD64_) + #define _AMD64_ + #endif +#elif defined(PROCESSOR_X86) + #if !defined(_X86_) + #define _X86_ + #endif +#elif defined(PROCESSOR_ARM) + #if !defined(_ARM_) + #define _ARM_ + #endif +#else + #error "Unsupported processr" +#endif + + +// Request a smaller header. It probably won't help too much, but it shouldn't +// hurt us either. +#define WIN32_LEAN_AND_MEAN +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +// GDI isn't used in many locations but it's easier to include it hear and +// undefine various pieces of trash than let unsuspecting code get trampled +// later. +#include + +#undef near +#undef far +#undef NEAR +#undef FAR + +#undef ERROR + +#undef TRANSPARENT +#undef OPAQUE +