18 #ifndef OTABSL_BASE_MACROS_H_
19 #define OTABSL_BASE_MACROS_H_
33 #define OTABSL_ARRAYSIZE(array) \
34 (sizeof(::absl::OTABSL_OPTION_NAMESPACE_NAME::macros_internal::ArraySizeHelper(array)))
38 namespace macros_internal {
41 template <
typename T,
size_t N>
69 namespace base_internal {
110 #ifdef OTABSL_FALLTHROUGH_INTENDED
111 #error "OTABSL_FALLTHROUGH_INTENDED should not be defined."
115 #if defined(__clang__) && defined(__has_warning)
116 #if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")
117 #define OTABSL_FALLTHROUGH_INTENDED [[clang::fallthrough]]
119 #elif defined(__GNUC__) && __GNUC__ >= 7
120 #define OTABSL_FALLTHROUGH_INTENDED [[gnu::fallthrough]]
123 #ifndef OTABSL_FALLTHROUGH_INTENDED
124 #define OTABSL_FALLTHROUGH_INTENDED \
148 #if defined(__clang__) && __cplusplus >= 201103L
149 #define OTABSL_DEPRECATED(message) __attribute__((deprecated(message)))
152 #ifndef OTABSL_DEPRECATED
153 #define OTABSL_DEPRECATED(message)
174 #if OTABSL_HAVE_ATTRIBUTE(enable_if)
175 #define OTABSL_BAD_CALL_IF(expr, msg) \
176 __attribute__((enable_if(expr, "Bad call trap"), unavailable(msg)))
192 #define OTABSL_ASSERT(expr) \
193 (false ? static_cast<void>(expr) : static_cast<void>(0))
195 #define OTABSL_ASSERT(expr) \
196 (OTABSL_PREDICT_TRUE((expr)) ? static_cast<void>(0) \
197 : [] { assert(false && #expr); }()) // NOLINT
200 #ifdef OTABSL_HAVE_EXCEPTIONS
201 #define OTABSL_INTERNAL_TRY try
202 #define OTABSL_INTERNAL_CATCH_ANY catch (...)
203 #define OTABSL_INTERNAL_RETHROW do { throw; } while (false)
204 #else // OTABSL_HAVE_EXCEPTIONS
205 #define OTABSL_INTERNAL_TRY if (true)
206 #define OTABSL_INTERNAL_CATCH_ANY else if (false)
207 #define OTABSL_INTERNAL_RETHROW do {} while (false)
208 #endif // OTABSL_HAVE_EXCEPTIONS
210 #endif // OTABSL_BASE_MACROS_H_