NVIDIA Iray: Base API
Home
Up
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
assert.h
Go to the documentation of this file.
1
//*****************************************************************************
2
// Copyright 1986, 2016 NVIDIA Corporation. All rights reserved.
3
//*****************************************************************************
8
//*****************************************************************************
9
10
#ifndef MI_BASE_ASSERT_H
11
#define MI_BASE_ASSERT_H
12
13
#include <
mi/base/config.h
>
14
15
namespace
mi {
16
17
namespace
base {
18
39
#ifndef mi_static_assert
54
#ifdef _MSC_VER
55
// Special case for Visual Studio 7.1, since __LINE__ would not work.
56
#define mi_static_assert(expr) \
57
typedef mi::base::static_assert_test<static_cast<int>( \
58
sizeof(mi::base::static_assert_failure<static_cast<bool>((expr))>))> \
59
MI_BASE_JOIN(static_assert_instance, __COUNTER__)
60
#else // _MSC_VER
61
#ifdef MI_COMPILER_GCC
62
#define mi_static_assert_attribute __attribute__((unused))
63
#else
64
#define mi_static_assert_attribute
65
#endif
66
#define mi_static_assert(expr) \
67
typedef mi::base::static_assert_test<static_cast<int>( \
68
sizeof(mi::base::static_assert_failure<static_cast<bool>((expr))>))> \
69
MI_BASE_JOIN(static_assert_instance, __LINE__) mi_static_assert_attribute
70
#endif // _MSC_VER
71
#endif // mi_static_assert
72
73
// helper definitions for the mi_static_assert above.
74
template
<
bool
>
struct
static_assert_failure;
75
template
<>
struct
static_assert_failure<true> {};
76
template
<
int
>
struct
static_assert_test {};
77
78
#if defined( mi_base_assert) && ! defined( mi_base_assert_msg) \
79
|| ! defined( mi_base_assert) && defined( mi_base_assert_msg)
80
error
"Only one of mi_base_assert and mi_base_assert_msg has been defined. Please define both."
81
#else
82
#ifndef mi_base_assert
83
95
#define mi_base_assert(expr) (static_cast<void>(0)) // valid but void null stmt
96
112
#define mi_base_assert_msg(expr, msg) (static_cast<void>(0)) // valid but void null stmt
113
114
// Just for doxygen, begin
115
120
#define mi_base_assert_enabled
121
#undef mi_base_assert_enabled
122
123
// Just for doxygen, end
124
125
#else // mi_base_assert
126
127
#define mi_base_assert_enabled
128
129
#endif // mi_base_assert
130
#endif // mi_base_assert xor mi_base_assert_msg
131
141
#if defined(__FUNCSIG__)
142
# define MI_BASE_ASSERT_FUNCTION __FUNCSIG__
143
#elif defined( __cplusplus) && defined(__GNUC__) && defined(__GNUC_MINOR__) \
144
&& ((__GNUC__ << 16) + __GNUC_MINOR__ >= (2 << 16) + 6)
145
# define MI_BASE_ASSERT_FUNCTION __PRETTY_FUNCTION__
146
#else
147
# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
148
# define MI_BASE_ASSERT_FUNCTION __func__
149
# else
150
# define MI_BASE_ASSERT_FUNCTION ("unknown")
151
# endif
152
#endif
153
// end group mi_base_assert
155
156
}
// namespace base
157
158
}
// namespace mi
159
160
#endif // MI_BASE_ASSERT_H
mi
base
assert.h
Generated on Fri Mar 4 2016 19:53:22. Build 250909.11169, Doxygen 1.8.4