LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
compiler_attributes.hpp
Go to the documentation of this file.
1/* Copyright 2021 - 2026 R. Thomas
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15#ifndef LIEF_COMPILER_ATTR_H
16#define LIEF_COMPILER_ATTR_H
17
18
19#if !defined(_MSC_VER)
20 #if __cplusplus >= 201103L
21 #define LIEF_CPP11
22 #if __cplusplus >= 201402L
23 #define LIEF_CPP14
24 #if __cplusplus >= 201703L
25 #define LIEF_CPP17
26 #if __cplusplus >= 202002L
27 #define LIEF_CPP20
28 #endif
29 #endif
30 #endif
31 #endif
32#elif defined(_MSC_VER)
33 #if _MSVC_LANG >= 201103L
34 #define LIEF_CPP11
35 #if _MSVC_LANG >= 201402L
36 #define LIEF_CPP14
37 #if _MSVC_LANG > 201402L
38 #define LIEF_CPP17
39 #if _MSVC_LANG >= 202002L
40 #define LIEF_CPP20
41 #endif
42 #endif
43 #endif
44 #endif
45#endif
46
47#if defined(__MINGW32__)
48 #define LIEF_DEPRECATED(reason)
49#elif defined(LIEF_CPP14)
50 #define LIEF_DEPRECATED(reason) [[deprecated(reason)]]
51#else
52 #define LIEF_DEPRECATED(reason) __attribute__((deprecated(reason)))
53#endif
54
55#if defined(LIEF_CPP17)
56 #define LIEF_MAYBE_UNUSED [[maybe_unused]]
57#elif defined(__GNUC__) || defined(__clang__)
58 #define LIEF_MAYBE_UNUSED __attribute__((unused))
59#elif defined(_MSC_VER)
60 #define LIEF_MAYBE_UNUSED __pragma(warning(suppress : 4100 4101))
61#else
62 #define LIEF_MAYBE_UNUSED
63#endif
64
65#if defined(__has_cpp_attribute)
66 #if __has_cpp_attribute(clang::lifetimebound)
67 #define LIEF_LIFETIMEBOUND [[clang::lifetimebound]]
68 #else
69 #define LIEF_LIFETIMEBOUND
70 #endif
71#else
72 #define LIEF_LIFETIMEBOUND
73#endif
74
75#endif