Debian Codegraph @

src/mpt/base/compiletime_warning.hpp

raw
1 /* SPDX-License-Identifier: BSL-1.0 OR BSD-3-Clause */
2
3 #ifndef MPT_BASE_COMPILETIME_WARNING_HPP
4 #define MPT_BASE_COMPILETIME_WARNING_HPP
5
6
7
8 #include "mpt/base/detect.hpp"
9 #include "mpt/base/preprocessor.hpp"
10
11
12
13 #if MPT_COMPILER_MSVC
14
15 #define MPT_WARNING(text) __pragma(message(__FILE__ "(" MPT_PP_DEFER(MPT_PP_STRINGIFY, __LINE__) "): Warning: " text))
16 #define MPT_WARNING_STATEMENT(text) __pragma(message(__FILE__ "(" MPT_PP_DEFER(MPT_PP_STRINGIFY, __LINE__) "): Warning: " text))
17
18 #elif MPT_COMPILER_GCC || MPT_COMPILER_CLANG
19
20 #define MPT_WARNING(text) _Pragma(MPT_PP_STRINGIFY(GCC warning text))
21 #define MPT_WARNING_STATEMENT(text) _Pragma(MPT_PP_STRINGIFY(GCC warning text))
22
23 #else
24
25 // portable #pragma message or #warning replacement
26 #define MPT_WARNING(text) \
27 static inline int MPT_PP_UNIQUE_IDENTIFIER(MPT_WARNING_NAME)() noexcept { \
28 int warning [[deprecated("Warning: " text)]] = 0; \
29 return warning; \
30 } \
31 /**/
32 #define MPT_WARNING_STATEMENT(text) \
33 int MPT_PP_UNIQUE_IDENTIFIER(MPT_WARNING_NAME) = []() { \
34 int warning [[deprecated("Warning: " text)]] = 0; \
35 return warning; \
36 }() /**/
37
38 #endif
39
40
41
42 #endif // MPT_BASE_COMPILETIME_WARNING_HPP