3#ifndef PL_INCLUDING_BASICS_H
4# error "Please don't include Assert.h directly, but instead include Foundation/Basics.h"
35using plAssertHandler = bool (*)(
const char* szSourceFile, plUInt32 uiLine,
const char* szFunction,
const char* szExpression,
const char* szAssertMsg);
37PL_FOUNDATION_DLL
bool plDefaultAssertHandler(
const char* szSourceFile, plUInt32 uiLine,
const char* szFunction,
const char* szExpression,
const char* szAssertMsg);
40PL_FOUNDATION_DLL plAssertHandler plGetAssertHandler();
43PL_FOUNDATION_DLL
void plSetAssertHandler(plAssertHandler handler);
46PL_FOUNDATION_DLL
bool plFailedCheck(
const char* szSourceFile, plUInt32 uiLine,
const char* szFunction,
const char* szExpression,
const class plFormatString& msg);
47PL_FOUNDATION_DLL
bool plFailedCheck(
const char* szSourceFile, plUInt32 uiLine,
const char* szFunction,
const char* szExpression,
const char* szMsg);
50inline const char* plFmt(
const char* szFormat)
55#if PL_ENABLED(PL_COMPILER_MSVC)
58PL_FOUNDATION_DLL
void MSVC_OutOfLine_DebugBreak(...);
61#ifdef BUILDSYSTEM_CLANG_TIDY
62[[noreturn]]
void ClangTidyDoNotReturn();
63# define PL_REPORT_FAILURE(szErrorMsg, ...) ClangTidyDoNotReturn()
67# define PL_REPORT_FAILURE(szErrorMsg, ...) \
70 if (plFailedCheck(PL_SOURCE_FILE, PL_SOURCE_LINE, PL_SOURCE_FUNCTION, "", plFmt(szErrorMsg, ##__VA_ARGS__))) \
75#ifdef BUILDSYSTEM_CLANG_TIDY
76# define PL_ASSERT_ALWAYS(bCondition, szErrorMsg, ...) \
79 if (!!(bCondition) == false) \
80 ClangTidyDoNotReturn(); \
83# define PL_ANALYSIS_ASSUME(bCondition) PL_ASSERT_ALWAYS(bCondition, "")
87# define PL_ASSERT_ALWAYS(bCondition, szErrorMsg, ...) \
90 PL_MSVC_ANALYSIS_WARNING_PUSH \
91 PL_MSVC_ANALYSIS_WARNING_DISABLE(6326) \
92 if (!!(bCondition) == false) \
94 if (plFailedCheck(PL_SOURCE_FILE, PL_SOURCE_LINE, PL_SOURCE_FUNCTION, #bCondition, plFmt(szErrorMsg, ##__VA_ARGS__))) \
97 PL_MSVC_ANALYSIS_WARNING_POP \
102# define PL_ANALYSIS_ASSUME(bCondition)
107#define PL_ASSERT_NOT_IMPLEMENTED PL_REPORT_FAILURE("Not implemented");
110#if PL_ENABLED(PL_COMPILE_FOR_DEBUG)
116# define PL_ASSERT_DEBUG PL_ASSERT_ALWAYS
123# define PL_ASSERT_DEBUG(bCondition, szErrorMsg, ...)
128#if PL_ENABLED(PL_COMPILE_FOR_DEVELOPMENT) || PL_ENABLED(PL_COMPILE_FOR_DEBUG)
135# define PL_ASSERT_DEV PL_ASSERT_ALWAYS
142# define PL_VERIFY PL_ASSERT_ALWAYS
151# define PL_ASSERT_DEV(bCondition, szErrorMsg, ...)
158# define PL_VERIFY(bCondition, szErrorMsg, ...) \
159 if (!!(bCondition) == false) \
165#if PL_DISABLE_RELEASE_ASSERTS
172# define PL_ASSERT_RELEASE(bCondition, szErrorMsg, ...)
181# define PL_ASSERT_RELEASE PL_ASSERT_ALWAYS
186#define PL_DEFAULT_CASE_NOT_IMPLEMENTED \
188 PL_ASSERT_NOT_IMPLEMENTED \