iceoryx_hoofs 2.0.5
Loading...
Searching...
No Matches
attributes.hpp
1// Copyright (c) 2021 by Apex.AI Inc. All rights reserved.
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// SPDX-License-Identifier: Apache-2.0
16#ifndef IOX_HOOFS_CXX_ATTRIBUTES_HPP
17#define IOX_HOOFS_CXX_ATTRIBUTES_HPP
18
19namespace iox
20{
21namespace cxx
22{
30// NOLINTNEXTLINE
31#define IOX_DISCARD_RESULT(expr) static_cast<void>(expr)
32
36// [[nodiscard]], [[gnu::warn_unused]] supported since gcc 4.8 (https://gcc.gnu.org/projects/cxx-status.html)
39#if defined(_WIN32)
40// On WIN32 we are using C++17 which makes the keyword [[nodiscard]] available
41// NOLINTNEXTLINE
42#define IOX_NO_DISCARD [[nodiscard]]
43#elif defined(__APPLE__) && defined(__clang__)
44// On APPLE we are using C++17 which makes the keyword [[nodiscard]] available
45// NOLINTNEXTLINE
46#define IOX_NO_DISCARD [[nodiscard, gnu::warn_unused]]
47#elif (defined(__clang__) && __clang_major__ >= 4)
48// NOLINTNEXTLINE
49#define IOX_NO_DISCARD [[gnu::warn_unused]]
50#elif (defined(__GNUC__) && __GNUC__ >= 5)
51// NOLINTNEXTLINE
52#define IOX_NO_DISCARD [[nodiscard, gnu::warn_unused]]
53#else
54// on an unknown platform we use for now nothing since we do not know what is supported there
55#define IOX_NO_DISCARD
56#endif
57
60// [[fallthrough]] supported since gcc 7 (https://gcc.gnu.org/projects/cxx-status.html)
63#if defined(_WIN32)
64// On WIN32 we are using C++17 which makes the keyword [[fallthrough]] available
65// NOLINTNEXTLINE
66#define IOX_FALLTHROUGH [[fallthrough]]
67#elif defined(__APPLE__) && defined(__clang__)
68// On APPLE we are using C++17 which makes the keyword [[fallthrough]] available
69// NOLINTNEXTLINE
70#define IOX_FALLTHROUGH [[fallthrough]]
71#elif (defined(__GNUC__) && __GNUC__ >= 7) && !defined(__clang__)
72// clang prints a warning therefore we exclude it here
73// NOLINTNEXTLINE
74#define IOX_FALLTHROUGH [[fallthrough]]
75#else
76// on an unknown platform we use for now nothing since we do not know what is supported there
77#define IOX_FALLTHROUGH
78#endif
79
84#if defined(__GNUC__) || defined(__clang__)
85// NOLINTNEXTLINE
86#define IOX_MAYBE_UNUSED [[gnu::unused]]
87#elif defined(_WIN32)
88// On WIN32 we are using C++17 which makes the attribute [[maybe_unused]] available
89// NOLINTNEXTLINE
90#define IOX_MAYBE_UNUSED [[maybe_unused]]
91// on an unknown platform we use for now nothing since we do not know what is supported there
92#else
93#define IOX_MAYBE_UNUSED
94#endif
95
96
97} // namespace cxx
98} // namespace iox
99
100#endif
building block to easily create free function for logging in a library context
Definition lockfree_queue.hpp:29