aboutsummaryrefslogtreecommitdiff
path: root/Src/external_dependencies/openmpt-trunk/common/mptBaseMacros.h
diff options
context:
space:
mode:
authorJean-Francois Mauguit <jfmauguit@mac.com>2024-09-24 09:03:25 -0400
committerGitHub <noreply@github.com>2024-09-24 09:03:25 -0400
commitbab614c421ed7ae329d26bf028c4a3b1d2450f5a (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/external_dependencies/openmpt-trunk/common/mptBaseMacros.h
parent4bde6044fddf053f31795b9eaccdd2a5a527d21f (diff)
parent20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (diff)
downloadwinamp-bab614c421ed7ae329d26bf028c4a3b1d2450f5a.tar.gz
Merge pull request #5 from WinampDesktop/community
Merge to main
Diffstat (limited to 'Src/external_dependencies/openmpt-trunk/common/mptBaseMacros.h')
-rw-r--r--Src/external_dependencies/openmpt-trunk/common/mptBaseMacros.h98
1 files changed, 98 insertions, 0 deletions
diff --git a/Src/external_dependencies/openmpt-trunk/common/mptBaseMacros.h b/Src/external_dependencies/openmpt-trunk/common/mptBaseMacros.h
new file mode 100644
index 00000000..95380bbd
--- /dev/null
+++ b/Src/external_dependencies/openmpt-trunk/common/mptBaseMacros.h
@@ -0,0 +1,98 @@
+/*
+ * mptBaseMacros.h
+ * ---------------
+ * Purpose: Basic assorted compiler-related helpers.
+ * Notes : (currently none)
+ * Authors: OpenMPT Devs
+ * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
+ */
+
+
+#pragma once
+
+#include "openmpt/all/BuildSettings.hpp"
+
+#include "mpt/base/preprocessor.hpp"
+#include "mpt/base/compiletime_warning.hpp"
+#include "mpt/base/macros.hpp"
+
+#if MPT_CXX_AT_LEAST(20)
+#include <version>
+#else // !C++20
+#include <array>
+#endif // C++20
+
+#include <array>
+#include <iterator>
+#include <type_traits>
+
+#include <cstddef>
+#include <cstdint>
+
+#include <stddef.h>
+#include <stdint.h>
+
+
+OPENMPT_NAMESPACE_BEGIN
+
+
+
+#define MPT_UNREFERENCED_PARAMETER(x) MPT_UNUSED(x)
+#define MPT_UNUSED_VARIABLE(x) MPT_UNUSED(x)
+// C++17 std::size
+#if MPT_CXX_AT_LEAST(17)
+namespace mpt
+{
+using std::size;
+} // namespace mpt
+#else
+namespace mpt
+{
+template <typename T>
+MPT_CONSTEXPR11_FUN auto size(const T &v) -> decltype(v.size())
+{
+ return v.size();
+}
+template <typename T, std::size_t N>
+MPT_CONSTEXPR11_FUN std::size_t size(const T (&)[N]) noexcept
+{
+ return N;
+}
+} // namespace mpt
+#endif
+// legacy
+#if MPT_COMPILER_MSVC
+OPENMPT_NAMESPACE_END
+#include <cstdlib>
+#include <stdlib.h>
+OPENMPT_NAMESPACE_BEGIN
+#define MPT_ARRAY_COUNT(x) _countof(x)
+#else
+#define MPT_ARRAY_COUNT(x) (sizeof((x)) / sizeof((x)[0]))
+#endif
+#define CountOf(x) MPT_ARRAY_COUNT(x)
+
+
+
+#if MPT_COMPILER_MSVC
+// warning LNK4221: no public symbols found; archive member will be inaccessible
+// There is no way to selectively disable linker warnings.
+// #pragma warning does not apply and a command line option does not exist.
+// Some options:
+// 1. Macro which generates a variable with a unique name for each file (which means we have to pass the filename to the macro)
+// 2. unnamed namespace containing any symbol (does not work for c++11 compilers because they actually have internal linkage now)
+// 3. An unused trivial inline function.
+// Option 3 does not actually solve the problem though, which leaves us with option 1.
+// In any case, for optimized builds, the linker will just remove the useless symbol.
+#define MPT_MSVC_WORKAROUND_LNK4221_CONCAT_DETAIL(x, y) x##y
+#define MPT_MSVC_WORKAROUND_LNK4221_CONCAT(x, y) MPT_MSVC_WORKAROUND_LNK4221_CONCAT_DETAIL(x, y)
+#define MPT_MSVC_WORKAROUND_LNK4221(x) int MPT_MSVC_WORKAROUND_LNK4221_CONCAT(mpt_msvc_workaround_lnk4221_, x) = 0;
+#endif
+
+#ifndef MPT_MSVC_WORKAROUND_LNK4221
+#define MPT_MSVC_WORKAROUND_LNK4221(x)
+#endif
+
+
+
+OPENMPT_NAMESPACE_END