| 1 |
/* |
| 2 |
* mptBaseMacros.h |
| 3 |
* --------------- |
| 4 |
* Purpose: Basic assorted compiler-related helpers. |
| 5 |
* Notes : (currently none) |
| 6 |
* Authors: OpenMPT Devs |
| 7 |
* The OpenMPT source code is released under the BSD license. Read LICENSE for more details. |
| 8 |
*/ |
| 9 |
|
| 10 |
|
| 11 |
#pragma once |
| 12 |
|
| 13 |
#include "openmpt/all/BuildSettings.hpp" |
| 14 |
|
| 15 |
#include "mpt/base/preprocessor.hpp" |
| 16 |
#include "mpt/base/compiletime_warning.hpp" |
| 17 |
#include "mpt/base/macros.hpp" |
| 18 |
|
| 19 |
#if MPT_CXX_AT_LEAST(20) |
| 20 |
#include <version> |
| 21 |
#else // !C++20 |
| 22 |
#include <array> |
| 23 |
#endif // C++20 |
| 24 |
|
| 25 |
#include <array> |
| 26 |
#include <iterator> |
| 27 |
#include <type_traits> |
| 28 |
|
| 29 |
#include <cstddef> |
| 30 |
#include <cstdint> |
| 31 |
|
| 32 |
#include <stddef.h> |
| 33 |
#include <stdint.h> |
| 34 |
|
| 35 |
|
| 36 |
OPENMPT_NAMESPACE_BEGIN |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
#define MPT_UNREFERENCED_PARAMETER(x) MPT_UNUSED(x) |
| 41 |
#define MPT_UNUSED_VARIABLE(x) MPT_UNUSED(x) |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
#if MPT_COMPILER_MSVC |
| 46 |
// warning LNK4221: no public symbols found; archive member will be inaccessible |
| 47 |
// There is no way to selectively disable linker warnings. |
| 48 |
// #pragma warning does not apply and a command line option does not exist. |
| 49 |
// Some options: |
| 50 |
// 1. Macro which generates a variable with a unique name for each file (which means we have to pass the filename to the macro) |
| 51 |
// 2. unnamed namespace containing any symbol (does not work for c++11 compilers because they actually have internal linkage now) |
| 52 |
// 3. An unused trivial inline function. |
| 53 |
// Option 3 does not actually solve the problem though, which leaves us with option 1. |
| 54 |
// In any case, for optimized builds, the linker will just remove the useless symbol. |
| 55 |
#define MPT_MSVC_WORKAROUND_LNK4221_CONCAT_DETAIL(x,y) x##y |
| 56 |
#define MPT_MSVC_WORKAROUND_LNK4221_CONCAT(x,y) MPT_MSVC_WORKAROUND_LNK4221_CONCAT_DETAIL(x,y) |
| 57 |
#define MPT_MSVC_WORKAROUND_LNK4221(x) int MPT_MSVC_WORKAROUND_LNK4221_CONCAT(mpt_msvc_workaround_lnk4221_,x) = 0; |
| 58 |
#endif |
| 59 |
|
| 60 |
#ifndef MPT_MSVC_WORKAROUND_LNK4221 |
| 61 |
#define MPT_MSVC_WORKAROUND_LNK4221(x) |
| 62 |
#endif |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
OPENMPT_NAMESPACE_END |