VCTR
Loading...
Searching...
No Matches
CompilerSpecificAttributes.h
1/*
2 ==============================================================================
3 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
5 Copyright 2022- by sonible GmbH.
6
7 This file is part of VCTR - Versatile Container Templates Reconceptualized.
8
9 VCTR is free software: you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License version 3
11 only, as published by the Free Software Foundation.
12
13 VCTR is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU Lesser General Public License version 3 for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 version 3 along with VCTR. If not, see <https://www.gnu.org/licenses/>.
20 ==============================================================================
21*/
22
23#define VCTR_TO_STRING(s) #s
24
25// VCTR_FORCEDINLINE enforces full inlining in release builds. In debug builds we want to preserve the possibility
26// to debug, so it does not affect inlining there
27#if VCTR_DEBUG
28#define VCTR_FORCEDINLINE
29#else
30#if VCTR_MSVC
31#define VCTR_FORCEDINLINE __forceinline
32#else
33#define VCTR_FORCEDINLINE inline __attribute__ ((always_inline))
34#endif
35#endif
36
37
38#if (VCTR_GCC || VCTR_CLANG)
39
40#define VCTR_JOIN_DIAGNOSTICS_STRINGS(x,y) VCTR_TO_STRING (x ## y)
41#define VCTR_DIAGNOSTIC_PRAGMA(compiler, x) _Pragma (VCTR_TO_STRING (compiler diagnostic x))
42
43#define VCTR_START_IGNORE_WARNING_CLANG_GCC(warning) \
44 VCTR_DIAGNOSTIC_PRAGMA (VCTR_COMPILER_NAME, push) \
45 VCTR_DIAGNOSTIC_PRAGMA (VCTR_COMPILER_NAME, ignored VCTR_JOIN_DIAGNOSTICS_STRINGS (-W, warning))
46#define VCTR_END_IGNORE_WARNING_CLANG_GCC \
47 VCTR_DIAGNOSTIC_PRAGMA (VCTR_COMPILER_NAME, pop)
48
49#else
50#define VCTR_START_IGNORE_WARNING_CLANG_GCC(warning)
51#define VCTR_END_IGNORE_WARNING_CLANG_GCC
52#endif
53
54#if VCTR_GCC
55#define VCTR_START_IGNORE_WARNING_GCC(warning) VCTR_START_IGNORE_WARNING_CLANG_GCC(warning)
56#define VCTR_END_IGNORE_WARNING_GCC VCTR_END_IGNORE_WARNING_CLANG_GCC
57#else
58#define VCTR_START_IGNORE_WARNING_GCC(warning)
59#define VCTR_END_IGNORE_WARNING_GCC
60#endif
61
62#if VCTR_CLANG
63#define VCTR_START_IGNORE_WARNING_CLANG(warning) VCTR_START_IGNORE_WARNING_CLANG_GCC(warning)
64#define VCTR_END_IGNORE_WARNING_CLANG VCTR_END_IGNORE_WARNING_CLANG_GCC
65#else
66#define VCTR_START_IGNORE_WARNING_CLANG(warning)
67#define VCTR_END_IGNORE_WARNING_CLANG
68#endif
69
70#if VCTR_MSVC
71#define VCTR_START_IGNORE_WARNING_MSVC(warningNumber) __pragma(warning(push)) __pragma(warning(disable:warningNumber))
72#define VCTR_END_IGNORE_WARNING_MSVC __pragma(warning(pop))
73#else
74#define VCTR_START_IGNORE_WARNING_MSVC(warning)
75#define VCTR_END_IGNORE_WARNING_MSVC
76#endif