Botan 3.13.0
Crypto and TLS for C&
api.h
Go to the documentation of this file.
1/*
2* (C) 2016,2025 Jack Lloyd
3*
4* Botan is released under the Simplified BSD License (see license.txt)
5*/
6
7#ifndef BOTAN_API_ANNOTATIONS_H_
8#define BOTAN_API_ANNOTATIONS_H_
9
10#include <botan/build.h>
11
12// NOLINTBEGIN(*-macro-usage)
13
14/**
15* Used to annotate API exports which are public and supported.
16* These APIs will not be broken/removed unless strictly required for
17* functionality or security, and only in new major versions.
18* @param maj The major version this public API was released in
19* @param min The minor version this public API was released in
20*/
21#define BOTAN_PUBLIC_API(maj, min) BOTAN_DLL
22
23/**
24* Used to annotate API exports which are public, but are now deprecated
25* and which will be removed in a future major release.
26*/
27#define BOTAN_DEPRECATED_API(msg) BOTAN_DEPRECATED(msg) BOTAN_DLL
28
29/**
30* Used to annotate API exports which are public and can be used by
31* applications if needed, but which are intentionally not documented,
32* and which may change incompatibly in a future major version.
33*/
34#define BOTAN_UNSTABLE_API BOTAN_DLL
35
36/**
37* Used to annotate API exports which are exported but only for the
38* purposes of testing. They should not be used by applications and
39* may be removed or changed without notice.
40*/
41#define BOTAN_TEST_API BOTAN_DLL
42
43/**
44* This is used to mark constructors which are currently not `explicit`
45* but which in a future major release be modified as such.
46*
47* TODO(Botan4) remove this macro and replace with `explicit`
48*/
49#if defined(__clang_analyzer__) || defined(BOTAN_DISABLE_DEPRECATED_FEATURES)
50 #define BOTAN_FUTURE_EXPLICIT explicit
51#else
52 #define BOTAN_FUTURE_EXPLICIT
53#endif
54
55/**
56* Used to annotate API exports which are exported but only for the
57* purposes of fuzzing. They should not be used by applications and
58* may be removed or changed without notice.
59*
60* They are only exported if the fuzzers are being built
61*/
62#if defined(BOTAN_FUZZERS_ARE_BEING_BUILT)
63 #define BOTAN_FUZZER_API BOTAN_DLL
64#else
65 #define BOTAN_FUZZER_API
66#endif
67
68/*
69* Define BOTAN_DEPRECATED
70*/
71#if !defined(BOTAN_NO_DEPRECATED_WARNINGS) && !defined(BOTAN_AMALGAMATION_H_) && !defined(BOTAN_IS_BEING_BUILT)
72
73 #define BOTAN_DEPRECATED(msg) [[deprecated(msg)]]
74
75 #if defined(__clang__)
76 #define BOTAN_DEPRECATED_HEADER(hdr) _Pragma("message \"this header is deprecated\"")
77 #define BOTAN_FUTURE_INTERNAL_HEADER(hdr) _Pragma("message \"this header will be made internal in the future\"")
78 #elif defined(_MSC_VER)
79 #if !defined(BOTAN_STRINGIFY) && !defined(BOTAN_STRINGIFY_2)
80 #define BOTAN_STRINGIFY_2(x) #x
81 #define BOTAN_STRINGIFY(x) BOTAN_STRINGIFY_2(x)
82 #endif
83 #define BOTAN_DEPRECATED_HEADER(hdr) \
84 __pragma(message(__FILE__ "(" BOTAN_STRINGIFY(__LINE__) "): this header is deprecated"))
85 #define BOTAN_FUTURE_INTERNAL_HEADER(hdr) \
86 __pragma(message(__FILE__ "(" BOTAN_STRINGIFY(__LINE__) "): this header will be made internal in the future"))
87 #elif defined(__GNUC__)
88 #define BOTAN_DEPRECATED_HEADER(hdr) _Pragma("GCC warning \"this header is deprecated\"")
89 #define BOTAN_FUTURE_INTERNAL_HEADER(hdr) \
90 _Pragma("GCC warning \"this header will be made internal in the future\"")
91 #endif
92
93#endif
94
95#if !defined(BOTAN_DEPRECATED)
96 #define BOTAN_DEPRECATED(msg)
97#endif
98
99#if !defined(BOTAN_DEPRECATED_HEADER)
100 #define BOTAN_DEPRECATED_HEADER(hdr)
101#endif
102
103#if !defined(BOTAN_FUTURE_INTERNAL_HEADER)
104 #define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
105#endif
106
107#if defined(__clang__)
108 #define BOTAN_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
109 #define BOTAN_DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS \
110 _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
111 #define BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE
112 #define BOTAN_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
113#elif defined(__GNUG__)
114 #define BOTAN_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
115 #define BOTAN_DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS \
116 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
117 #define BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE
118 #define BOTAN_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
119#elif defined(_MSC_VER)
120 #define BOTAN_DIAGNOSTIC_PUSH __pragma(warning(push))
121 #define BOTAN_DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS __pragma(warning(disable : 4996))
122 #define BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE __pragma(warning(disable : 4250))
123 #define BOTAN_DIAGNOSTIC_POP __pragma(warning(pop))
124#else
125 #define BOTAN_DIAGNOSTIC_PUSH
126 #define BOTAN_DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS
127 #define BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE
128 #define BOTAN_DIAGNOSTIC_POP
129#endif
130
131// NOLINTEND(*-macro-usage)
132
133#endif