Botan 3.9.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 #define BOTAN_DEPRECATED_HEADER(hdr) __pragma(message("this header is deprecated"))
80 #define BOTAN_FUTURE_INTERNAL_HEADER(hdr) __pragma(message("this header will be made internal in the future"))
81 #elif defined(__GNUC__)
82 #define BOTAN_DEPRECATED_HEADER(hdr) _Pragma("GCC warning \"this header is deprecated\"")
83 #define BOTAN_FUTURE_INTERNAL_HEADER(hdr) \
84 _Pragma("GCC warning \"this header will be made internal in the future\"")
85 #endif
86
87#endif
88
89#if !defined(BOTAN_DEPRECATED)
90 #define BOTAN_DEPRECATED(msg)
91#endif
92
93#if !defined(BOTAN_DEPRECATED_HEADER)
94 #define BOTAN_DEPRECATED_HEADER(hdr)
95#endif
96
97#if !defined(BOTAN_FUTURE_INTERNAL_HEADER)
98 #define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
99#endif
100
101#if defined(__clang__)
102 #define BOTAN_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
103 #define BOTAN_DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS \
104 _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
105 #define BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE
106 #define BOTAN_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
107#elif defined(__GNUG__)
108 #define BOTAN_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
109 #define BOTAN_DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS \
110 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
111 #define BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE
112 #define BOTAN_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
113#elif defined(_MSC_VER)
114 #define BOTAN_DIAGNOSTIC_PUSH __pragma(warning(push))
115 #define BOTAN_DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS __pragma(warning(disable : 4996))
116 #define BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE __pragma(warning(disable : 4250))
117 #define BOTAN_DIAGNOSTIC_POP __pragma(warning(pop))
118#else
119 #define BOTAN_DIAGNOSTIC_PUSH
120 #define BOTAN_DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS
121 #define BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE
122 #define BOTAN_DIAGNOSTIC_POP
123#endif
124
125// NOLINTEND(*-macro-usage)
126
127#endif