Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
has_feature.hpp
Go to the documentation of this file.
1// Copyright 2024, Toyota Motor Corporation
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_COMPILER_SUPPORT_PLATFORM_QUERIES_HAS_FEATURE_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_COMPILER_SUPPORT_PLATFORM_QUERIES_HAS_FEATURE_HPP_
7
8// IWYU pragma: private
9// IWYU pragma: friend "arene/base/compiler_support/platform_queries/.*"
10
11// NOLINTBEGIN(cppcoreguidelines-macro-usage) Explicitly providing compiler support macro functions
12// parasoft-begin-suppress AUTOSAR-A16_0_1-d-2 "Conditional defines permitted by A16-0-1 Permit #2"
13// parasoft-begin-suppress AUTOSAR-A16_0_1-a-2 "Conditional defines permitted by A16-0-1 Permit #2"
14
15/// @def ARENE_HAS_FEATURE
16/// @brief A platform support query for testing if a supplied feature is defined.
17/// @param ... The name of the feature to query for.
18/// @return if @c __has_feature is defined, the result of @c __has_feature(__VA_ARGS__), otherwise @c 0 .
19///
20/// Example usage testing for the @c address_sanitizer feature:
21/// @code{c++}
22/// #if ARENE_HAS_FEATURE(address_sanitizer)
23/// @endcode
24///
25/// @note @c __has_feature is a clang-specific facility. It generally shouldn't be used in user code, and instead should
26/// be used only as a building block to other platform support queries.
27///
28
29#if defined(__has_feature)
30#define ARENE_HAS_FEATURE(...) __has_feature(__VA_ARGS__)
31#else
32#define ARENE_HAS_FEATURE(...) 0
33#endif // checking for __has_feature
34
35// NOLINTEND(cppcoreguidelines-macro-usage) Explicitly providing compiler support macro functions
36// parasoft-end-suppress AUTOSAR-A16_0_1-d-2
37// parasoft-end-suppress AUTOSAR-A16_0_1-a-2
38
39#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_COMPILER_SUPPORT_PLATFORM_QUERIES_HAS_FEATURE_HPP_