| 1 | // Copyright (C) 2022 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QEXCEPTIONHANDLING_H |
| 5 | #define QEXCEPTIONHANDLING_H |
| 6 | |
| 7 | #include <QtCore/qtconfigmacros.h> |
| 8 | #include <QtCore/qcompilerdetection.h> |
| 9 | #include <QtCore/qtcoreexports.h> |
| 10 | |
| 11 | #if 0 |
| 12 | #pragma qt_class(QtExceptionHandling) |
| 13 | #pragma qt_sync_stop_processing |
| 14 | #endif |
| 15 | |
| 16 | QT_BEGIN_NAMESPACE |
| 17 | |
| 18 | /* These wrap try/catch so we can switch off exceptions later. |
| 19 | |
| 20 | Beware - do not use more than one QT_CATCH per QT_TRY, and do not use |
| 21 | the exception instance in the catch block. |
| 22 | If you can't live with those constraints, don't use these macros. |
| 23 | Use the QT_NO_EXCEPTIONS macro to protect your code instead. |
| 24 | */ |
| 25 | Q_NORETURN Q_DECL_COLD_FUNCTION Q_CORE_EXPORT void qTerminate() noexcept; |
| 26 | #ifdef QT_NO_EXCEPTIONS |
| 27 | # define QT_TRY if (true) |
| 28 | # define QT_CATCH(A) else |
| 29 | # define QT_THROW(A) qt_noop() |
| 30 | # define QT_RETHROW qt_noop() |
| 31 | #else |
| 32 | # define QT_TRY try |
| 33 | # define QT_CATCH(A) catch (A) |
| 34 | # define QT_THROW(A) throw A |
| 35 | # define QT_RETHROW throw |
| 36 | #endif |
| 37 | |
| 38 | QT_END_NAMESPACE |
| 39 | |
| 40 | #endif // QEXCEPTIONHANDLING_H |
| 41 | |