Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qssgassert_p.h
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QSSGASSERT_P_H
5#define QSSGASSERT_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/qglobal.h>
19#include <QtQuick3DUtils/private/qtquick3dutilsexports_p.h>
20
22
23Q_QUICK3DUTILS_PRIVATE_EXPORT void qssgWriteAssertLocation(const char *msg);
24
26
27#define QSSG_ASSERT_STRINGIFY_HELPER(x) #x
28#define QSSG_ASSERT_STRINGIFY(x) QSSG_ASSERT_STRINGIFY_HELPER(x)
29#define QSSG_ASSERT_STRING_X(msg) QT_PREPEND_NAMESPACE(qssgWriteAssertLocation)(msg)
30#define QSSG_ASSERT_STRING(cond) QSSG_ASSERT_STRING_X(\
31 "\"" cond"\" in file " __FILE__ ", line " QSSG_ASSERT_STRINGIFY(__LINE__))
32
33// The 'do {...} while (0)' idiom is not used for the main block here to be
34// able to use 'break' and 'continue' as 'actions'.
35
36#define QSSG_ASSERT(cond, action) if (Q_LIKELY(cond)) {} else { QSSG_ASSERT_STRING(#cond); action; } do {} while (0)
37#define QSSG_ASSERT_X(cond, msg, action) if (Q_LIKELY(cond)) {} else { QSSG_ASSERT_STRING_X(msg); action; } do {} while (0)
38#define QSSG_CHECK(cond) if (Q_LIKELY(cond)) {} else { QSSG_ASSERT_STRING(#cond); } do {} while (0)
39#define QSSG_CHECK_X(cond, msg) if (Q_LIKELY(cond)) {} else { QSSG_ASSERT_STRING_X(msg); } do {} while (0)
40#define QSSG_GUARD(cond) ((Q_LIKELY(cond)) ? true : (QSSG_ASSERT_STRING(#cond), false))
41#define QSSG_GUARD_X(cond, msg) ((Q_LIKELY(cond)) ? true : (QSSG_ASSERT_STRING_X(msg), false))
42
43#endif // QSSGASSERT_P_H
Combined button and popup list for selecting options.
QT_BEGIN_NAMESPACE Q_QUICK3DUTILS_PRIVATE_EXPORT void qssgWriteAssertLocation(const char *msg)
Collection of assert checks that causes a soft or hard assert depending on the build.