win32/windows: undef ERROR

This commit is contained in:
Danny Robson 2019-03-04 11:25:53 +11:00
parent e61216a593
commit 5aefb2f82a

View File

@ -1,62 +1,64 @@
#pragma once #pragma once
#include "../platform.hpp" #include "../platform.hpp"
// Include various useful Windows headers in a way that won't break anything // 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 // that isn't aware of Microsoft's propensity to define away large swathes of
// frequently used symbols. // frequently used symbols.
#if defined(_WINDOWS_) #if defined(_WINDOWS_)
#error "windows headers have already been included" #error "windows headers have already been included"
#endif #endif
// Based off the approach outlined at: // Based off the approach outlined at:
// https://aras-p.info/blog/2018/01/12/Minimizing-windows.h/ // https://aras-p.info/blog/2018/01/12/Minimizing-windows.h/
// Predefine the hardware platform macros that the headers will expect. // Predefine the hardware platform macros that the headers will expect.
#if defined(PROCESSOR_AMD64) #if defined(PROCESSOR_AMD64)
#if !defined(_AMD64_) #if !defined(_AMD64_)
#define _AMD64_ #define _AMD64_
#endif #endif
#elif defined(PROCESSOR_X86) #elif defined(PROCESSOR_X86)
#if !defined(_X86_) #if !defined(_X86_)
#define _X86_ #define _X86_
#endif #endif
#elif defined(PROCESSOR_ARM) #elif defined(PROCESSOR_ARM)
#if !defined(_ARM_) #if !defined(_ARM_)
#define _ARM_ #define _ARM_
#endif #endif
#else #else
#error "Unsupported processr" #error "Unsupported processr"
#endif #endif
// Request a smaller header. It probably won't help too much, but it shouldn't // Request a smaller header. It probably won't help too much, but it shouldn't
// hurt us either. // hurt us either.
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include <windef.h> #include <windef.h>
#include <fileapi.h> #include <fileapi.h>
#include <synchapi.h> #include <synchapi.h>
#include <debugapi.h> #include <debugapi.h>
#include <memoryapi.h> #include <memoryapi.h>
#include <handleapi.h> #include <handleapi.h>
#include <processthreadsapi.h> #include <processthreadsapi.h>
#include <errhandlingapi.h> #include <errhandlingapi.h>
// GDI isn't used in many locations but it's easier to include it hear and // 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 // undefine various pieces of trash than let unsuspecting code get trampled
// later. // later.
#include <wingdi.h> #include <wingdi.h>
#undef near #undef near
#undef far #undef far
#undef NEAR #undef NEAR
#undef FAR #undef FAR
#undef TRANSPARENT #undef ERROR
#undef OPAQUE
#undef TRANSPARENT
#undef OPAQUE