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#if VCTR_MSVC
26#define VCTR_TARGET(arch)
27#else
28#define VCTR_TARGET(arch) __attribute__ ((target (arch)))
29#endif
30
31// VCTR_FORCEDINLINE enforces full inlining in release builds. In debug builds we want to preserve the possibility
32// to debug, so it does not affect inlining there
33#if VCTR_DEBUG
34#define VCTR_FORCEDINLINE
35#else
36#if VCTR_MSVC
37#define VCTR_FORCEDINLINE __forceinline
38#else
39#define VCTR_FORCEDINLINE inline __attribute__ ((always_inline))
40#endif
41#endif
42
43
44#if (VCTR_GCC || VCTR_CLANG)
45
46#define VCTR_JOIN_DIAGNOSTICS_STRINGS(x,y) VCTR_TO_STRING (x ## y)
47#define VCTR_DIAGNOSTIC_PRAGMA(compiler, x) _Pragma (VCTR_TO_STRING (compiler diagnostic x))
48
49#define VCTR_START_IGNORE_WARNING_CLANG_GCC(warning) \
50 VCTR_DIAGNOSTIC_PRAGMA (VCTR_COMPILER_NAME, push) \
51 VCTR_DIAGNOSTIC_PRAGMA (VCTR_COMPILER_NAME, ignored VCTR_JOIN_DIAGNOSTICS_STRINGS (-W, warning))
52#define VCTR_END_IGNORE_WARNING_CLANG_GCC \
53 VCTR_DIAGNOSTIC_PRAGMA (VCTR_COMPILER_NAME, pop)
54
55#else
56#define VCTR_START_IGNORE_WARNING_CLANG_GCC(warning)
57#define VCTR_END_IGNORE_WARNING_CLANG_GCC
58#endif
59
60#if VCTR_GCC
61#define VCTR_START_IGNORE_WARNING_GCC(warning) VCTR_START_IGNORE_WARNING_CLANG_GCC(warning)
62#define VCTR_END_IGNORE_WARNING_GCC VCTR_END_IGNORE_WARNING_CLANG_GCC
63#else
64#define VCTR_START_IGNORE_WARNING_GCC(warning)
65#define VCTR_END_IGNORE_WARNING_GCC
66#endif
67
68#if VCTR_CLANG
69#define VCTR_START_IGNORE_WARNING_CLANG(warning) VCTR_START_IGNORE_WARNING_CLANG_GCC(warning)
70#define VCTR_END_IGNORE_WARNING_CLANG VCTR_END_IGNORE_WARNING_CLANG_GCC
71#else
72#define VCTR_START_IGNORE_WARNING_CLANG(warning)
73#define VCTR_END_IGNORE_WARNING_CLANG
74#endif
75
76#if VCTR_MSVC
77#define VCTR_START_IGNORE_WARNING_MSVC(warningNumber) __pragma(warning(push)) __pragma(warning(disable:warningNumber))
78#define VCTR_END_IGNORE_WARNING_MSVC __pragma(warning(pop))
79#else
80#define VCTR_START_IGNORE_WARNING_MSVC(warning)
81#define VCTR_END_IGNORE_WARNING_MSVC
82#endif