7#include <QtCore/qcompilerdetection.h>
8#include <QtCore/qtconfigmacros.h>
9#include <QtCore/qtcoreexports.h>
10#include <QtCore/qtnoop.h>
13#pragma qt_class(QtAssert)
14#pragma qt_sync_stop_processing
19#if defined(__cplusplus)
21#if !defined(Q_CC_MSVC_ONLY)
25Q_CORE_EXPORT
void qt_assert(
const char *assertion,
const char *
file,
int line)
noexcept;
28# if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS)
29# define Q_ASSERT(cond) static_cast<void>(false && (cond))
31# define Q_ASSERT(cond) ((cond) ? static_cast<void>(0) : qt_assert(#cond, __FILE__, __LINE__))
35#if !defined(Q_CC_MSVC_ONLY)
42#if !defined(Q_ASSERT_X)
43# if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS)
44# define Q_ASSERT_X(cond, where, what) static_cast<void>(false && (cond))
46# define Q_ASSERT_X(cond, where, what) ((cond) ? static_cast<void>(0) : qt_assert_x(where, what, __FILE__, __LINE__))
54#ifdef QT_NO_EXCEPTIONS
55# if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS)
56# define Q_CHECK_PTR(p) qt_noop()
58# define Q_CHECK_PTR(p) do {if (!(p)) qt_check_pointer(__FILE__,__LINE__);} while (false)
61# define Q_CHECK_PTR(p) do { if (!(p)) qBadAlloc(); } while (false)
68#define Q_UNREACHABLE() \
70 Q_ASSERT_X(false, "Q_UNREACHABLE()", "Q_UNREACHABLE was reached");\
71 Q_UNREACHABLE_IMPL();\
74#ifndef Q_UNREACHABLE_RETURN
75# ifdef Q_COMPILER_COMPLAINS_ABOUT_RETURN_AFTER_UNREACHABLE
76# define Q_UNREACHABLE_RETURN(...) Q_UNREACHABLE()
78# define Q_UNREACHABLE_RETURN(...) do { Q_UNREACHABLE(); return __VA_ARGS__; } while (0)
82#define Q_ASSUME(Expr) \
83 [] (bool valueOfExpression) {\
84 Q_ASSERT_X(valueOfExpression, "Q_ASSUME()", "Assumption in Q_ASSUME(\"" #Expr "\") was not correct");\
85 Q_ASSUME_IMPL(valueOfExpression);\
90# define Q_STATIC_ASSERT(Condition) static_assert(bool(Condition), #Condition)
91# define Q_STATIC_ASSERT_X(Condition, Message) static_assert(bool(Condition), Message)
93#elif defined(Q_COMPILER_STATIC_ASSERT)
95# define Q_STATIC_ASSERT(Condition) _Static_assert(!!(Condition), #Condition)
96# define Q_STATIC_ASSERT_X(Condition, Message) _Static_assert(!!(Condition), Message)
99# define Q_STATIC_ASSERT_PRIVATE_JOIN(A, B) Q_STATIC_ASSERT_PRIVATE_JOIN_IMPL(A, B)
100# define Q_STATIC_ASSERT_PRIVATE_JOIN_IMPL(A, B) A ## B
102# define Q_STATIC_ASSERT(Condition) \
103 typedef char Q_STATIC_ASSERT_PRIVATE_JOIN(q_static_assert_result, __COUNTER__) [(Condition) ? 1 : -1];
105# define Q_STATIC_ASSERT(Condition) \
106 typedef char Q_STATIC_ASSERT_PRIVATE_JOIN(q_static_assert_result, __LINE__) [(Condition) ? 1 : -1];
108# define Q_STATIC_ASSERT_X(Condition, Message) Q_STATIC_ASSERT(Condition)
Combined button and popup list for selecting options.
void qt_assert_x(const char *where, const char *what, const char *file, int line) noexcept
void qt_check_pointer(const char *n, int l) noexcept
#define Q_DECL_COLD_FUNCTION
Q_CHECK_PTR(a=new int[80])