IDS peak AFL v2.0.2
Loading...
Searching...
No Matches
peak_common_defines.h
Go to the documentation of this file.
1
10
11#pragma once
12
13// clang-format off
14#define PEAK_COMMON_CPP_STANDARD_14 201402L
15#define PEAK_COMMON_CPP_STANDARD_17 201702L
16// clang-format on
17
18#ifdef __has_c_attribute
19# define PEAK_COMMON_has_c_attribute(x) __has_c_attribute(x)
20#else
21# define PEAK_COMMON_has_c_attribute(x) 0
22#endif
23
24#if defined(__cplusplus)
25# define PEAK_COMMON_CPP_STANDARD __cplusplus
26#elif defined(_MSVC_LANG)
27# define PEAK_COMMON_CPP_STANDARD _MSVC_LANG
28#endif
29
30#if defined(_MSC_VER)
31# define PEAK_COMMON_BEGIN_DISABLE_DEPRECATED_WARNINGS __pragma(warning(push)) __pragma(warning(disable : 4'996))
32# define PEAK_COMMON_END_DISABLE_DEPRECATED_WARNINGS __pragma(warning(pop))
33#elif defined(__clang__) || defined(__GNUC__)
34# define PEAK_COMMON_BEGIN_DISABLE_DEPRECATED_WARNINGS \
35 _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
36# define PEAK_COMMON_END_DISABLE_DEPRECATED_WARNINGS _Pragma("GCC diagnostic pop")
37#else
38# define PEAK_COMMON_BEGIN_DISABLE_DEPRECATED_WARNINGS
39# define PEAK_COMMON_END_DISABLE_DEPRECATED_WARNINGS
40#endif
41
42#if !defined(PEAK_COMMON_NO_WARN_DEPRECATED) \
43 && ((defined(PEAK_COMMON_CPP_STANDARD) && PEAK_COMMON_CPP_STANDARD >= PEAK_COMMON_CPP_STANDARD_14) \
44 || PEAK_COMMON_has_c_attribute(deprecated))
53# define PEAK_COMMON_DEPRECATED_MSG(MESSAGE) [[deprecated(MESSAGE)]]
54#elif !defined(PEAK_COMMON_NO_WARN_DEPRECATED) && (defined(__clang__) || defined(__GNUC__) || defined(__GNUG__))
55# define PEAK_COMMON_DEPRECATED_MSG(MESSAGE) __attribute__((deprecated(MESSAGE)))
56#else
57# define PEAK_COMMON_DEPRECATED_MSG(MESSAGE)
58#endif
59
60#if !defined(PEAK_COMMON_NO_WARN_DEPRECATED) && defined(PEAK_COMMON_CPP_STANDARD) \
61 && PEAK_COMMON_CPP_STANDARD >= PEAK_COMMON_CPP_STANDARD_17
70# define PEAK_COMMON_DEPRECATED_ENUM_MSG(MESSAGE) [[deprecated(MESSAGE)]]
71#elif !defined(PEAK_COMMON_NO_WARN_DEPRECATED) && (defined(__clang__) || defined(__GNUC__) || defined(__GNUG__))
72# define PEAK_COMMON_DEPRECATED_ENUM_MSG(MESSAGE) __attribute__((deprecated(MESSAGE)))
73#else
74# define PEAK_COMMON_DEPRECATED_ENUM_MSG(MESSAGE)
75#endif
76
77#if (defined(PEAK_COMMON_CPP_STANDARD) && PEAK_COMMON_CPP_STANDARD >= PEAK_COMMON_CPP_STANDARD_17) \
78 || PEAK_COMMON_has_c_attribute(nodiscard)
87# define PEAK_COMMON_NO_DISCARD [[nodiscard]]
88#elif defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
89# define PEAK_COMMON_NO_DISCARD __attribute__((warn_unused_result))
90#elif defined(_MSC_VER)
91# include <sal.h>
92# define PEAK_COMMON_NO_DISCARD _Check_return_
93#else
94# define PEAK_COMMON_NO_DISCARD
95#endif
96
97#if (defined(PEAK_COMMON_CPP_STANDARD) && PEAK_COMMON_CPP_STANDARD >= PEAK_COMMON_CPP_STANDARD_17) \
98 || PEAK_COMMON_has_c_attribute(maybe_unused)
107# define PEAK_COMMON_MAYBE_UNUSED [[maybe_unused]]
108#elif defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
109# define PEAK_COMMON_MAYBE_UNUSED __attribute__((unused))
110#else
111# define PEAK_COMMON_MAYBE_UNUSED
112#endif