aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-10-15 16:29:38 +0200
committerStefan Boberg <[email protected]>2021-10-15 16:29:38 +0200
commitbb258b7bf62c5021d2ccde38107efcfdfc52ddd0 (patch)
tree6d641ac4ecc04373e19a9c80776a47ba5b590eaf
parentzencore: added ZEN_THIRD_PARTY_INCLUDES_START/ZEN_THIRD_PARTY_INCLUDES_END (diff)
downloadzen-bb258b7bf62c5021d2ccde38107efcfdfc52ddd0.tar.xz
zen-bb258b7bf62c5021d2ccde38107efcfdfc52ddd0.zip
zencore: Enabled MSC warning 4668 to get warnings when preprocessor macros are used without an explicit definition
Also fixed up various code to compile with this, by using ZEN_THIRD_PARTY_INCLUDES_START/ZEN_THIRD_PARTY_INCLUDES_END macros Removed prewindows.h/postwindows.h since they are no longer to be used due to the above
-rw-r--r--zen/cmds/cache.cpp11
-rw-r--r--zen/cmds/run.cpp11
-rw-r--r--zencore/include/zencore/fmtutils.h4
-rw-r--r--zencore/include/zencore/logging.h8
-rw-r--r--zencore/include/zencore/postwindows.h3
-rw-r--r--zencore/include/zencore/prewindows.h1
-rw-r--r--zencore/include/zencore/windows.h5
-rw-r--r--zencore/include/zencore/zencore.h1
-rw-r--r--zencore/iobuffer.cpp9
-rw-r--r--zencore/memory.cpp2
-rw-r--r--zencore/thread.cpp5
-rw-r--r--zencore/zencore.vcxproj3
-rw-r--r--zencore/zencore.vcxproj.filters3
-rw-r--r--zenhttp/include/zenhttp/httpclient.h9
-rw-r--r--zenhttp/include/zenhttp/zenhttp.h8
-rw-r--r--zenserver-test/zenserver-test.cpp10
-rw-r--r--zenserver/compute/apply.cpp6
-rw-r--r--zenserver/config.cpp1
-rw-r--r--zenserver/config.h4
-rw-r--r--zenserver/diag/formatters.h7
-rw-r--r--zenserver/diag/logging.cpp5
-rw-r--r--zenserver/experimental/usnjournal.h3
-rw-r--r--zenserver/upstream/jupiter.cpp11
-rw-r--r--zenserver/upstream/zen.cpp11
-rw-r--r--zenserver/zenserver.cpp12
-rw-r--r--zenstore/filecas.cpp9
26 files changed, 77 insertions, 85 deletions
diff --git a/zen/cmds/cache.cpp b/zen/cmds/cache.cpp
index 202bf9246..2a911c8c7 100644
--- a/zen/cmds/cache.cpp
+++ b/zen/cmds/cache.cpp
@@ -9,16 +9,9 @@
#include <memory>
-// cpr ////////////////////////////////////////////////////////////////////
-//
-// For some reason, these don't seem to stick, so we disable the warnings
-//# define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING 1
-//# define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS 1
-#pragma warning(push)
-#pragma warning(disable : 4004)
-#pragma warning(disable : 4996)
+ZEN_THIRD_PARTY_INCLUDES_START
#include <cpr/cpr.h>
-#pragma warning(pop)
+ZEN_THIRD_PARTY_INCLUDES_END
using namespace fmt::literals;
diff --git a/zen/cmds/run.cpp b/zen/cmds/run.cpp
index 19b5c8980..8cbf13566 100644
--- a/zen/cmds/run.cpp
+++ b/zen/cmds/run.cpp
@@ -17,16 +17,9 @@
#include <filesystem>
-// cpr ////////////////////////////////////////////////////////////////////
-//
-// For some reason, these don't seem to stick, so we disable the warnings
-//# define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING 1
-//# define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS 1
-#pragma warning(push)
-#pragma warning(disable : 4004)
-#pragma warning(disable : 4996)
+ZEN_THIRD_PARTY_INCLUDES_START
#include <cpr/cpr.h>
-#pragma warning(pop)
+ZEN_THIRD_PARTY_INCLUDES_END
#if ZEN_PLATFORM_WINDOWS
# pragma comment(lib, "Crypt32.lib")
diff --git a/zencore/include/zencore/fmtutils.h b/zencore/include/zencore/fmtutils.h
index 29e2ae78a..7e60c2bef 100644
--- a/zencore/include/zencore/fmtutils.h
+++ b/zencore/include/zencore/fmtutils.h
@@ -6,7 +6,11 @@
#include <zencore/string.h>
#include <zencore/uid.h>
+
+ZEN_THIRD_PARTY_INCLUDES_START
#include <fmt/format.h>
+ZEN_THIRD_PARTY_INCLUDES_END
+
#include <filesystem>
#include <string_view>
diff --git a/zencore/include/zencore/logging.h b/zencore/include/zencore/logging.h
index 0838cfe80..5a038dd3c 100644
--- a/zencore/include/zencore/logging.h
+++ b/zencore/include/zencore/logging.h
@@ -2,11 +2,11 @@
#pragma once
-// clang-format off
-#include "prewindows.h"
+#include <zencore/zencore.h>
+
+ZEN_THIRD_PARTY_INCLUDES_START
#include <spdlog/spdlog.h>
-#include "postwindows.h"
-// clang-format on
+ZEN_THIRD_PARTY_INCLUDES_END
#include <string_view>
diff --git a/zencore/include/zencore/postwindows.h b/zencore/include/zencore/postwindows.h
deleted file mode 100644
index 35b7db3af..000000000
--- a/zencore/include/zencore/postwindows.h
+++ /dev/null
@@ -1,3 +0,0 @@
-// Copyright Epic Games, Inc. All Rights Reserved.
-
-#undef GetObject
diff --git a/zencore/include/zencore/prewindows.h b/zencore/include/zencore/prewindows.h
deleted file mode 100644
index 0bc74e49b..000000000
--- a/zencore/include/zencore/prewindows.h
+++ /dev/null
@@ -1 +0,0 @@
-// Copyright Epic Games, Inc. All Rights Reserved.
diff --git a/zencore/include/zencore/windows.h b/zencore/include/zencore/windows.h
index 2b6dc4839..621621ae8 100644
--- a/zencore/include/zencore/windows.h
+++ b/zencore/include/zencore/windows.h
@@ -2,7 +2,7 @@
#pragma once
-#include "prewindows.h"
+ZEN_THIRD_PARTY_INCLUDES_START
struct IUnknown; // Workaround for "combaseapi.h(229): error C2187: syntax error: 'identifier' was unexpected here" when using /permissive-
#ifndef NOMINMAX
@@ -10,5 +10,6 @@ struct IUnknown; // Workaround for "combaseapi.h(229): error C2187: syntax erro
#endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
+#undef GetObject
-#include "postwindows.h"
+ZEN_THIRD_PARTY_INCLUDES_END
diff --git a/zencore/include/zencore/zencore.h b/zencore/include/zencore/zencore.h
index 3367b39ef..d654770d0 100644
--- a/zencore/include/zencore/zencore.h
+++ b/zencore/include/zencore/zencore.h
@@ -62,7 +62,6 @@
#if ZEN_COMPILER_MSC
# pragma warning(disable : 4324) // warning C4324: '<type>': structure was padded due to alignment specifier
-# pragma warning(default : 4668) // warning C4668: 'symbol' is not defined as a preprocessor macro, replacing with '0' for 'directives'
#endif
#ifndef ZEN_THIRD_PARTY_INCLUDES_START
diff --git a/zencore/iobuffer.cpp b/zencore/iobuffer.cpp
index 119e37d0b..6cee3f60d 100644
--- a/zencore/iobuffer.cpp
+++ b/zencore/iobuffer.cpp
@@ -15,7 +15,9 @@
#include <system_error>
#if ZEN_USE_MIMALLOC
+ZEN_THIRD_PARTY_INCLUDES_START
# include <mimalloc.h>
+ZEN_THIRD_PARTY_INCLUDES_END
#endif
#if ZEN_PLATFORM_WINDOWS
@@ -390,9 +392,12 @@ IoBufferBuilder::ReadFromFileMaybe(IoBuffer& InBuffer)
DWORD dwNumberOfBytesRead = 0;
BOOL Success = ::ReadFile(FileRef.FileHandle, OutBuffer.MutableData(), DWORD(NumberOfBytesToRead), &dwNumberOfBytesRead, &Ovl);
- ZEN_ASSERT(dwNumberOfBytesRead == NumberOfBytesToRead);
+ if (!Success)
+ {
+ ThrowLastError("ReadFile failed in IoBufferBuilder::ReadFromFileMaybe");
+ }
- // TODO: error handling
+ ZEN_ASSERT(dwNumberOfBytesRead == NumberOfBytesToRead);
return OutBuffer;
#else
diff --git a/zencore/memory.cpp b/zencore/memory.cpp
index da78ae3a8..62c81076d 100644
--- a/zencore/memory.cpp
+++ b/zencore/memory.cpp
@@ -6,7 +6,9 @@
#ifdef ZEN_PLATFORM_WINDOWS
# include <malloc.h>
+ZEN_THIRD_PARTY_INCLUDES_START
# include <mimalloc.h>
+ZEN_THIRD_PARTY_INCLUDES_END
#else
# include <cstdlib>
#endif
diff --git a/zencore/thread.cpp b/zencore/thread.cpp
index 6f27ee528..da711fe89 100644
--- a/zencore/thread.cpp
+++ b/zencore/thread.cpp
@@ -2,7 +2,6 @@
#include <zencore/thread.h>
-#include <fmt/format.h>
#include <zencore/except.h>
#include <zencore/string.h>
@@ -12,6 +11,10 @@
# include <unistd.h>
#endif
+ZEN_THIRD_PARTY_INCLUDES_START
+#include <fmt/format.h>
+ZEN_THIRD_PARTY_INCLUDES_END
+
namespace zen {
#if ZEN_PLATFORM_WINDOWS
diff --git a/zencore/zencore.vcxproj b/zencore/zencore.vcxproj
index 421802d3f..95b9eace5 100644
--- a/zencore/zencore.vcxproj
+++ b/zencore/zencore.vcxproj
@@ -115,6 +115,7 @@
<ClInclude Include="include\zencore\atomic.h" />
<ClInclude Include="include\zencore\base64.h" />
<ClInclude Include="include\zencore\blake3.h" />
+ <ClInclude Include="include\zencore\blockingqueue.h" />
<ClInclude Include="include\zencore\compactbinaryvalue.h" />
<ClInclude Include="include\zencore\compositebuffer.h" />
<ClInclude Include="include\zencore\crc32.h" />
@@ -131,8 +132,6 @@
<ClInclude Include="include\zencore\memory.h" />
<ClInclude Include="include\zencore\meta.h" />
<ClInclude Include="include\zencore\mpscqueue.h" />
- <ClInclude Include="include\zencore\postwindows.h" />
- <ClInclude Include="include\zencore\prewindows.h" />
<ClInclude Include="include\zencore\refcount.h" />
<ClInclude Include="include\zencore\scopeguard.h" />
<ClInclude Include="include\zencore\session.h" />
diff --git a/zencore/zencore.vcxproj.filters b/zencore/zencore.vcxproj.filters
index e701e9354..1aedf9eab 100644
--- a/zencore/zencore.vcxproj.filters
+++ b/zencore/zencore.vcxproj.filters
@@ -36,8 +36,6 @@
<ClInclude Include="include\zencore\compositebuffer.h" />
<ClInclude Include="include\zencore\crc32.h" />
<ClInclude Include="include\zencore\meta.h" />
- <ClInclude Include="include\zencore\prewindows.h" />
- <ClInclude Include="include\zencore\postwindows.h" />
<ClInclude Include="include\zencore\logging.h" />
<ClInclude Include="include\zencore\session.h" />
<ClInclude Include="include\zencore\testutils.h" />
@@ -45,6 +43,7 @@
<ClInclude Include="include\zencore\mpscqueue.h" />
<ClInclude Include="include\zencore\base64.h" />
<ClInclude Include="include\zencore\compactbinaryvalue.h" />
+ <ClInclude Include="include\zencore\blockingqueue.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="sha1.cpp" />
diff --git a/zenhttp/include/zenhttp/httpclient.h b/zenhttp/include/zenhttp/httpclient.h
index aa36a8027..9ece86111 100644
--- a/zenhttp/include/zenhttp/httpclient.h
+++ b/zenhttp/include/zenhttp/httpclient.h
@@ -10,14 +10,9 @@
#include <zencore/windows.h>
-// For some reason, these don't seem to stick, so we disable the warnings
-//# define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING 1
-//# define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS 1
-#pragma warning(push)
-#pragma warning(disable : 4004)
-#pragma warning(disable : 4996)
+ZEN_THIRD_PARTY_INCLUDES_START
#include <cpr/cpr.h>
-#pragma warning(pop)
+ZEN_THIRD_PARTY_INCLUDES_END
namespace zen {
diff --git a/zenhttp/include/zenhttp/zenhttp.h b/zenhttp/include/zenhttp/zenhttp.h
index 165f34b48..59c64b31f 100644
--- a/zenhttp/include/zenhttp/zenhttp.h
+++ b/zenhttp/include/zenhttp/zenhttp.h
@@ -4,6 +4,14 @@
#include <zencore/zencore.h>
+#ifndef ZEN_WITH_HTTPSYS
+# if ZEN_PLATFORM_WINDOWS
+# define ZEN_WITH_HTTPSYS 1
+# else
+# define ZEN_WITH_HTTPSYS 0
+# endif
+#endif
+
#define ZENHTTP_API // Placeholder to allow DLL configs in the future
namespace zen {
diff --git a/zenserver-test/zenserver-test.cpp b/zenserver-test/zenserver-test.cpp
index fe21aa834..9c9b73042 100644
--- a/zenserver-test/zenserver-test.cpp
+++ b/zenserver-test/zenserver-test.cpp
@@ -23,7 +23,9 @@
#include <zenutil/zenserverprocess.h>
#if ZEN_USE_MIMALLOC
+ZEN_THIRD_PARTY_INCLUDES_START
# include <mimalloc.h>
+ZEN_THIRD_PARTY_INCLUDES_END
#endif
#include <http_parser.h>
@@ -32,7 +34,11 @@
# pragma comment(lib, "Crypt32.lib")
# pragma comment(lib, "Wldap32.lib")
#endif
+
+ZEN_THIRD_PARTY_INCLUDES_START
#include <cpr/cpr.h>
+#undef GetObject
+ZEN_THIRD_PARTY_INCLUDES_END
#include <ppl.h>
#include <atomic>
@@ -594,10 +600,6 @@ private:
//////////////////////////////////////////////////////////////////////////
#if 0
-# include <cpr/cpr.h>
-
-# pragma comment(lib, "Crypt32.lib")
-# pragma comment(lib, "Wldap32.lib")
int
main()
diff --git a/zenserver/compute/apply.cpp b/zenserver/compute/apply.cpp
index a522aa35b..053c262c2 100644
--- a/zenserver/compute/apply.cpp
+++ b/zenserver/compute/apply.cpp
@@ -16,18 +16,16 @@
#include <zenstore/CAS.h>
#include <zenstore/cidstore.h>
-// clang-format off
#if ZEN_PLATFORM_WINDOWS
-# include <zencore/prewindows.h>
+ZEN_THIRD_PARTY_INCLUDES_START
# include <AccCtrl.h>
# include <AclAPI.h>
# include <sddl.h>
# include <UserEnv.h>
# pragma comment(lib, "UserEnv.lib")
# include <atlbase.h>
-# include <zencore/postwindows.h>
+ZEN_THIRD_PARTY_INCLUDES_END
#endif
-// clang-format on
#include <filesystem>
#include <span>
diff --git a/zenserver/config.cpp b/zenserver/config.cpp
index 8d7254ae1..cbdbebb03 100644
--- a/zenserver/config.cpp
+++ b/zenserver/config.cpp
@@ -7,6 +7,7 @@
#include <zencore/fmtutils.h>
#include <zencore/iobuffer.h>
#include <zencore/string.h>
+#include <zenhttp/zenhttp.h>
#pragma warning(push)
#pragma warning(disable : 4267) // warning C4267: '=': conversion from 'size_t' to 'US', possible loss of data
diff --git a/zenserver/config.h b/zenserver/config.h
index eaafc31bb..d68549616 100644
--- a/zenserver/config.h
+++ b/zenserver/config.h
@@ -5,6 +5,10 @@
#include <filesystem>
#include <string>
+#ifndef ZEN_ENABLE_MESH
+# define ZEN_ENABLE_MESH 0
+#endif
+
struct ZenServerOptions
{
bool IsDebug = false;
diff --git a/zenserver/diag/formatters.h b/zenserver/diag/formatters.h
index d4eeeb31c..d55765612 100644
--- a/zenserver/diag/formatters.h
+++ b/zenserver/diag/formatters.h
@@ -2,13 +2,10 @@
#pragma once
+ZEN_THIRD_PARTY_INCLUDES_START
#include <fmt/format.h>
-
-#pragma warning(push)
-#pragma warning(disable : 4004)
-#pragma warning(disable : 4996)
#include <cpr/cpr.h>
-#pragma warning(pop)
+ZEN_THIRD_PARTY_INCLUDES_END
template<>
struct fmt::formatter<cpr::Response>
diff --git a/zenserver/diag/logging.cpp b/zenserver/diag/logging.cpp
index 7a7773cba..6e2559f1f 100644
--- a/zenserver/diag/logging.cpp
+++ b/zenserver/diag/logging.cpp
@@ -4,6 +4,7 @@
#include "config.h"
+ZEN_THIRD_PARTY_INCLUDES_START
#include <spdlog/async.h>
#include <spdlog/async_logger.h>
#include <spdlog/pattern_formatter.h>
@@ -13,10 +14,10 @@
#include <spdlog/sinks/msvc_sink.h>
#include <spdlog/sinks/rotating_file_sink.h>
#include <spdlog/sinks/stdout_color_sinks.h>
-#include <spdlog/spdlog.h>
+ZEN_THIRD_PARTY_INCLUDES_END
+
#include <zencore/string.h>
#include <memory>
-#include "spdlog/sinks/basic_file_sink.h"
// Custom logging -- test code, this should be tweaked
diff --git a/zenserver/experimental/usnjournal.h b/zenserver/experimental/usnjournal.h
index 9c1008d52..688823953 100644
--- a/zenserver/experimental/usnjournal.h
+++ b/zenserver/experimental/usnjournal.h
@@ -2,9 +2,12 @@
#pragma once
+#include <zencore/zencore.h>
#include <zencore/windows.h>
+ZEN_THIRD_PARTY_INCLUDES_START
#include <winioctl.h>
+ZEN_THIRD_PARTY_INCLUDES_END
#include <filesystem>
diff --git a/zenserver/upstream/jupiter.cpp b/zenserver/upstream/jupiter.cpp
index 1c43f1bc6..556a2124d 100644
--- a/zenserver/upstream/jupiter.cpp
+++ b/zenserver/upstream/jupiter.cpp
@@ -6,21 +6,16 @@
#include "diag/formatters.h"
#include "diag/logging.h"
-#include <fmt/format.h>
#include <zencore/compactbinary.h>
#include <zencore/iobuffer.h>
#include <zencore/iohash.h>
#include <zencore/string.h>
#include <zencore/thread.h>
-// For some reason, these don't seem to stick, so we disable the warnings
-//# define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING 1
-//# define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS 1
-#pragma warning(push)
-#pragma warning(disable : 4004)
-#pragma warning(disable : 4996)
+ZEN_THIRD_PARTY_INCLUDES_START
#include <cpr/cpr.h>
-#pragma warning(pop)
+#include <fmt/format.h>
+ZEN_THIRD_PARTY_INCLUDES_END
#if ZEN_PLATFORM_WINDOWS
# pragma comment(lib, "Crypt32.lib")
diff --git a/zenserver/upstream/zen.cpp b/zenserver/upstream/zen.cpp
index 6141fd397..14333f45a 100644
--- a/zenserver/upstream/zen.cpp
+++ b/zenserver/upstream/zen.cpp
@@ -12,16 +12,9 @@
#include "diag/formatters.h"
#include "diag/logging.h"
-// cpr ////////////////////////////////////////////////////////////////////
-//
-// For some reason, these don't seem to stick, so we disable the warnings
-//# define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING 1
-//# define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS 1
-#pragma warning(push)
-#pragma warning(disable : 4004)
-#pragma warning(disable : 4996)
+ZEN_THIRD_PARTY_INCLUDES_START
#include <cpr/cpr.h>
-#pragma warning(pop)
+ZEN_THIRD_PARTY_INCLUDES_END
#include <xxhash.h>
#include <gsl/gsl-lite.hpp>
diff --git a/zenserver/zenserver.cpp b/zenserver/zenserver.cpp
index a1cd01d33..c9b52604d 100644
--- a/zenserver/zenserver.cpp
+++ b/zenserver/zenserver.cpp
@@ -16,17 +16,21 @@
#include <zenstore/cidstore.h>
#include <zenutil/zenserverprocess.h>
-#include <fmt/format.h>
-
#if ZEN_USE_MIMALLOC
+ZEN_THIRD_PARTY_INCLUDES_START
# include <mimalloc-new-delete.h>
# include <mimalloc.h>
+ZEN_THIRD_PARTY_INCLUDES_END
#endif
+ZEN_THIRD_PARTY_INCLUDES_START
+#include <fmt/format.h>
#include <asio.hpp>
+#include <lua.hpp>
+ZEN_THIRD_PARTY_INCLUDES_END
+
#include <exception>
#include <list>
-#include <lua.hpp>
#include <optional>
#include <regex>
#include <set>
@@ -64,7 +68,9 @@
#if USE_SENTRY
# define SENTRY_BUILD_STATIC 1
+ZEN_THIRD_PARTY_INCLUDES_START
# include <sentry.h>
+ZEN_THIRD_PARTY_INCLUDES_END
// Sentry currently does not automatically add all required Windows
// libraries to the linker when consumed via vcpkg
diff --git a/zenstore/filecas.cpp b/zenstore/filecas.cpp
index f928f5c21..a37450cd8 100644
--- a/zenstore/filecas.cpp
+++ b/zenstore/filecas.cpp
@@ -22,14 +22,9 @@
#include <functional>
#include <unordered_map>
-// clang-format off
-#include <zencore/prewindows.h>
-
-struct IUnknown; // Workaround for "combaseapi.h(229): error C2187: syntax error: 'identifier' was unexpected here" when using /permissive-
+ZEN_THIRD_PARTY_INCLUDES_START
#include <atlfile.h>
-
-#include <zencore/postwindows.h>
-// clang-format on
+ZEN_THIRD_PARTY_INCLUDES_END
namespace zen {