From 783da580a54df404165dabcb7b4230f34713d595 Mon Sep 17 00:00:00 2001 From: Vasyl Skorych Date: Tue, 31 Oct 2023 18:48:50 +0100 Subject: [PATCH] build: Add safe Windows.h include --- SimulatorCore/ModelsManager.h | 3 +-- Utilities/DyssolSystemFunctions.h | 2 +- Utilities/DyssolWindows.h | 24 ++++++++++++++++++++++++ Utilities/FileSystem.cpp | 2 +- Utilities/StringFunctions.cpp | 4 +--- Utilities/Utilities.vcxproj | 1 + Utilities/Utilities.vcxproj.filters | 3 +++ 7 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 Utilities/DyssolWindows.h diff --git a/SimulatorCore/ModelsManager.h b/SimulatorCore/ModelsManager.h index e682e547..66ec57f5 100644 --- a/SimulatorCore/ModelsManager.h +++ b/SimulatorCore/ModelsManager.h @@ -10,8 +10,7 @@ #include #ifdef _MSC_VER -#define NOMINMAX -#include +#include "DyssolWindows.h" typedef HINSTANCE DYSSOL_LIBRARY_INSTANCE; typedef FARPROC DYSSOL_CREATE_FUNCTION_TYPE; diff --git a/Utilities/DyssolSystemFunctions.h b/Utilities/DyssolSystemFunctions.h index 3c507395..87523fdf 100644 --- a/Utilities/DyssolSystemFunctions.h +++ b/Utilities/DyssolSystemFunctions.h @@ -7,7 +7,7 @@ #include #include #include -#include +#include "DyssolWindows.h" #include #include #endif diff --git a/Utilities/DyssolWindows.h b/Utilities/DyssolWindows.h new file mode 100644 index 00000000..65d0569e --- /dev/null +++ b/Utilities/DyssolWindows.h @@ -0,0 +1,24 @@ +/* Copyright (c) 2023, DyssolTEC GmbH. + * All rights reserved. This file is part of Dyssol. See LICENSE file for license information. */ + + /* + * Safely includes un-defining some Windows defines. + */ + +#pragma once + +#ifdef _WIN32 + #ifdef NOMINMAX + #include + #undef AddPort + #undef CreateFile + #undef GetObject + #else + #define NOMINMAX + #include + #undef NOMINMAX + #undef AddPort + #undef CreateFile + #undef GetObject + #endif +#endif \ No newline at end of file diff --git a/Utilities/FileSystem.cpp b/Utilities/FileSystem.cpp index 991ff564..7ba8e689 100644 --- a/Utilities/FileSystem.cpp +++ b/Utilities/FileSystem.cpp @@ -6,7 +6,7 @@ #ifdef _MSC_VER #include #include -#include +#include "DyssolWindows.h" #else #include #include diff --git a/Utilities/StringFunctions.cpp b/Utilities/StringFunctions.cpp index 014aee7a..3d6f4b80 100644 --- a/Utilities/StringFunctions.cpp +++ b/Utilities/StringFunctions.cpp @@ -2,9 +2,7 @@ #include "StringFunctions.h" #ifdef _MSC_VER -#include -#undef AddPort -#undef CreateFile +#include "DyssolWindows.h" #else #include #endif diff --git a/Utilities/Utilities.vcxproj b/Utilities/Utilities.vcxproj index c2a1ecfb..8230fafe 100644 --- a/Utilities/Utilities.vcxproj +++ b/Utilities/Utilities.vcxproj @@ -127,6 +127,7 @@ + diff --git a/Utilities/Utilities.vcxproj.filters b/Utilities/Utilities.vcxproj.filters index f1128682..71b74cf0 100644 --- a/Utilities/Utilities.vcxproj.filters +++ b/Utilities/Utilities.vcxproj.filters @@ -66,6 +66,9 @@ Header Files + + Header Files +