Math API nvidia_logo_transpbg.gif Up
assert.h
Go to the documentation of this file.
1/***************************************************************************************************
2 * Copyright 2024 NVIDIA Corporation. All rights reserved.
3 **************************************************************************************************/
8
9#ifndef MI_BASE_ASSERT_H
10#define MI_BASE_ASSERT_H
11
12#include <mi/base/config.h>
13
14namespace mi {
15
16namespace base {
17
52#ifndef mi_static_assert
53#ifdef MI_COMPILER_GCC
54#define mi_static_assert_attribute __attribute__((unused))
55#else
56#define mi_static_assert_attribute
57#endif
58#define mi_static_assert(expr) \
59 typedef mi::base::static_assert_test<static_cast<int>( \
60 sizeof(mi::base::static_assert_failure<static_cast<bool>((expr))>))> \
61 MI_BASE_JOIN(static_assert_instance, __LINE__) mi_static_assert_attribute
62#endif // mi_static_assert
63
64// helper definitions for the mi_static_assert above.
65template <bool> struct static_assert_failure;
66template <> struct static_assert_failure<true> {};
67template <int> struct static_assert_test {};
68
69#if defined( mi_base_assert) && ! defined( mi_base_assert_msg) \
70 || ! defined( mi_base_assert) && defined( mi_base_assert_msg)
71error "Only one of mi_base_assert and mi_base_assert_msg has been defined. Please define both."
72#else
73#ifndef mi_base_assert
74
86#define mi_base_assert(expr) (static_cast<void>(0)) // valid but void null stmt
87
103#define mi_base_assert_msg(expr, msg) (static_cast<void>(0)) // valid but void null stmt
104
105// Just for doxygen, begin
106
111#define mi_base_assert_enabled
112#undef mi_base_assert_enabled
113
114// Just for doxygen, end
115
116#else // mi_base_assert
117
118#define mi_base_assert_enabled
119
120#endif // mi_base_assert
121#endif // mi_base_assert xor mi_base_assert_msg
122
132#if defined(__FUNCSIG__)
133# define MI_BASE_ASSERT_FUNCTION __FUNCSIG__
134#elif defined( __cplusplus) && defined(__GNUC__) && defined(__GNUC_MINOR__) \
135 && ((__GNUC__ << 16) + __GNUC_MINOR__ >= (2 << 16) + 6)
136# define MI_BASE_ASSERT_FUNCTION __PRETTY_FUNCTION__
137#else
138# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
139# define MI_BASE_ASSERT_FUNCTION __func__
140# else
141# define MI_BASE_ASSERT_FUNCTION ("unknown")
142# endif
143#endif
144 // end group mi_base_assert
146
147} // namespace base
148
149} // namespace mi
150
151#endif // MI_BASE_ASSERT_H
Configuration of the Base API.
std::basic_ostream<C, T> & error(std::basic_ostream<C, T> &ostream)
Manipulator for mi::base::Log_stream.
Definition: ilogger.h:542
Common namespace for APIs of NVIDIA Advanced Rendering Center GmbH.
Definition: math.h:22