Add #include wrapper to fix min/max <Windows.h> mess

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2023-10-18 12:51:49 +02:00
parent 856be3a0d8
commit 16a86cf350
6 changed files with 29 additions and 5 deletions

View File

@ -8,7 +8,7 @@
#include <assert.h>
#include <stddef.h>
#ifdef _WIN32
#include <windows.h>
#include "windows.h"
#include <sal.h>
#endif
#include <type_traits>

View File

@ -7,7 +7,7 @@
#include "compat.hpp"
#ifdef _WIN32
#include <windows.h>
#include "windows.h"
#include <intrin.h>
#include <intsafe.h>
#endif

View File

@ -15,7 +15,7 @@
#include <stdint.h>
#include <stdlib.h>
#if defined(_WIN32)
#include <windows.h>
#include "windows.h"
#include <asptlb.h>
#include <objidl.h>
#include <WinSock2.h>

View File

@ -14,7 +14,7 @@
#include <stdio.h>
#include <time.h>
#if defined(_WIN32)
#include <windows.h>
#include "windows.h"
#include <rpc.h>
#elif defined(__APPLE__)
#include <uuid/uuid.h>

View File

@ -7,7 +7,7 @@
#include "compat.hpp"
#ifdef _WIN32
#include <windows.h>
#include "windows.h"
#include <oaidl.h>
#include <tchar.h>
#else

24
include/stdex/windows.h Normal file
View File

@ -0,0 +1,24 @@
/*
SPDX-License-Identifier: MIT
Copyright © 2023 Amebis
*/
#pragma once
// Windows.h #defines min and max, which collides with std::min and std::max.
// Not only the collision problem, #defining min and max is plain wrong as it
// causes multiple evaluations of parameter expressions.
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <windows.h>
// In case somebody #included <windows.h> before us without #defining NOMINMAX
#ifdef min
#undef min
#endif
#ifdef max
#undef max
#endif