iceoryx2
C++ Language Bindings
Loading...
Searching...
No Matches
deprecation_marker.hpp
Go to the documentation of this file.
1// Copyright (c) 2023 by ekxide IO GmbH. All rights reserved.
2// Copyright (c) 2025 Contributors to the Eclipse Foundation
3//
4// See the NOTICE file(s) distributed with this work for additional
5// information regarding copyright ownership.
6//
7// This program and the accompanying materials are made available under the
8// terms of the Apache Software License 2.0 which is available at
9// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license
10// which is available at https://opensource.org/licenses/MIT.
11//
12// SPDX-License-Identifier: Apache-2.0 OR MIT
13
14#ifndef IOX2_BB_UTILITY_DEPRECATION_MARKER_HPP
15#define IOX2_BB_UTILITY_DEPRECATION_MARKER_HPP
16
17// #include "iceoryx_versions.hpp"
18// FIXME introduce versions for iceoryx2
19#define ICEORYX_VERSION_MAJOR 0
20
21namespace iox2 {
22namespace legacy {
23namespace detail {
25} // namespace detail
26}
27} // namespace iox
28
29// NOLINTJUSTIFICATION there is no other way to create the intended functionality for the deprecation marker
30// NOLINTBEGIN(cppcoreguidelines-macro-usage)
31
32#define IOX2_INTERNAL_NEXT_DEPRECATED_VERSION 3
33
34#define IOX2_INTERNAL_DEPRECATED_STINGIFY_HELPER_EXPAMD(NUM) #NUM
35#define IOX2_INTERNAL_DEPRECATED_STINGIFY_HELPER(NUM) IOX2_INTERNAL_DEPRECATED_STINGIFY_HELPER_EXPAMD(NUM)
36
37// clang-format off
39 "The iceoryx major version changed to v" IOX2_INTERNAL_DEPRECATED_STINGIFY_HELPER(ICEORYX_VERSION_MAJOR) "!\n"
40 "The following steps need to be done to fix this error: \n"
41 " - increment 'IOX2_INTERNAL_NEXT_DEPRECATED_VERSION'\n"
42 " - update 'IOX2_INTERNAL_DEPRECATED_SINCE_V" IOX2_INTERNAL_DEPRECATED_STINGIFY_HELPER(ICEORYX_VERSION_MAJOR)
43 " to call 'IOX2_INTERNAL_DEPRECATED_SINCE(VERSION, MESSAGE)'\n"
44 " - update 'IOX2_INTERNAL_DEPRECATED_HEADER_SINCE_V" IOX2_INTERNAL_DEPRECATED_STINGIFY_HELPER(ICEORYX_VERSION_MAJOR)
45 " to call 'IOX2_INTERNAL_DEPRECATED_HEADER_SINCE(VERSION, MESSAGE)'");
46// clang-format on
47
48
49// BEGIN IOX2_DEPRECATED_HEADER_SINCE macros
50
51// when the namespace is called 'header' the warning will be "warning: 'header' is deprecated: Deprecated since v#.0
52// ..." with the file and line where the 'IOX2_DEPRECATED_HEADER_SINCE' macro is used
53#define IOX2_INTERNAL_DEPRECATED_HEADER_SINCE(VERSION, MESSAGE) \
54 namespace iox2 { \
55 namespace legacy { \
56 namespace detail { \
57 namespace \
58 [[deprecated("Deprecated since v" #VERSION ".0 and will be removed at a later version! " MESSAGE)]] header { \
59 using iox2::legacy::detail::DeprecationMarker; \
60 } \
61 using header::DeprecationMarker; \
62 } \
63 }
64
65// clang-format off
66// The 'IOX2_INTERNAL_DEPRECATED_HEADER_SINCE_V#' macros call either 'IOX2_INTERNAL_DEPRECATED_HEADER_SINCE' if the
67// specific version is deprecated or expand to an empty macro. Here an example with V1 being deprecated and V2 not yet
68// ----
69// #define IOX2_INTERNAL_DEPRECATED_HEADER_SINCE_V1(VERSION, MESSAGE) IOX2_INTERNAL_DEPRECATED_HEADER_SINCE(VERSION, MESSAGE)
70// #define IOX2_INTERNAL_DEPRECATED_HEADER_SINCE_V2(VERSION, MESSAGE)
71// ----
72// clang-format on
73
74#define IOX2_INTERNAL_DEPRECATED_HEADER_SINCE_V1(VERSION, MESSAGE) \
75 IOX2_INTERNAL_DEPRECATED_HEADER_SINCE(VERSION, MESSAGE)
76
77#define IOX2_INTERNAL_DEPRECATED_HEADER_SINCE_V2(VERSION, MESSAGE) \
78 IOX2_INTERNAL_DEPRECATED_HEADER_SINCE(VERSION, MESSAGE)
79
80#define IOX2_INTERNAL_DEPRECATED_HEADER_SINCE_V3(VERSION, MESSAGE)
81
82#define IOX2_INTERNAL_DEPRECATED_HEADER_SINCE_V4(VERSION, MESSAGE)
83
84// This indirection is required to expand defines passed to 'IOX2_DEPRECATED_HEADER_SINCE' make code like this work
85// ----
86// #define V 3
87// IOX2_DEPRECATED_HEADER_SINCE(V, "Please include 'iox/foo.hpp' instead.")
88// ----
89#define IOX2_INTERNAL_DEPRECATED_HEADER_SINCE_EXPANSION(VERSION, MESSAGE) \
90 IOX2_INTERNAL_DEPRECATED_HEADER_SINCE_V##VERSION(VERSION, MESSAGE)
91
100#define IOX2_DEPRECATED_HEADER_SINCE(VERSION, MESSAGE) IOX2_INTERNAL_DEPRECATED_HEADER_SINCE_EXPANSION(VERSION, MESSAGE)
101
102// END IOX2_DEPRECATED_HEADER_SINCE macros
103
104
105// BEGIN IOX2_DEPRECATED_SINCE macros
106
107#define IOX2_INTERNAL_DEPRECATED_SINCE(VERSION, MESSAGE) \
108 [[deprecated("Deprecated since v" #VERSION ".0 and will be removed at a later version! " MESSAGE)]]
109
110// The 'IOX2_INTERNAL_DEPRECATED_SINCE_V#' macros call either 'IOX2_INTERNAL_DEPRECATED_SINCE' if the
111// specific version is deprecated or expand to an empty macro. Here an example with V1 being deprecated and V2 not yet
112// ----
113// #define IOX2_INTERNAL_DEPRECATED_SINCE_V1(VERSION, MESSAGE) IOX2_INTERNAL_DEPRECATED_SINCE(VERSION, MESSAGE)
114// #define IOX2_INTERNAL_DEPRECATED_SINCE_V2(VERSION, MESSAGE)
115// ----
116
117#define IOX2_INTERNAL_DEPRECATED_SINCE_V1(VERSION, MESSAGE) IOX2_INTERNAL_DEPRECATED_SINCE(VERSION, MESSAGE)
118
119#define IOX2_INTERNAL_DEPRECATED_SINCE_V2(VERSION, MESSAGE) IOX2_INTERNAL_DEPRECATED_SINCE(VERSION, MESSAGE)
120
121#define IOX2_INTERNAL_DEPRECATED_SINCE_V3(VERSION, MESSAGE)
122
123#define IOX2_INTERNAL_DEPRECATED_SINCE_V4(VERSION, MESSAGE)
124
125// This indirection is required to expand defines passed to 'IOX2_DEPRECATED_SINCE' make code like this work
126// ----
127// #define V 3
128// IOX2_DEPRECATED_SINCE(V, "Please use 'iox2::legacy::foo' instead.") void bar() {}
129// ----
130#define IOX2_INTERNAL_DEPRECATED_SINCE_EXPANSION(VERSION, MESSAGE) \
131 IOX2_INTERNAL_DEPRECATED_SINCE_V##VERSION(VERSION, MESSAGE)
132
139#define IOX2_DEPRECATED_SINCE(VERSION, MESSAGE) IOX2_INTERNAL_DEPRECATED_SINCE_EXPANSION(VERSION, MESSAGE)
140
141// END IOX2_DEPRECATED_SINCE macros
142
143// NOLINTEND(cppcoreguidelines-macro-usage)
144
145#endif // IOX2_BB_UTILITY_DEPRECATION_MARKER_HPP
#define ICEORYX_VERSION_MAJOR
#define IOX2_INTERNAL_NEXT_DEPRECATED_VERSION
#define IOX2_INTERNAL_DEPRECATED_STINGIFY_HELPER(NUM)