From cb7f77559b1682e7655af5a88b5bbeb63899eca4 Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 18 Mar 2021 18:14:09 +1100 Subject: Move assert and debug trace functions into their own header Debugging.h. PLATFORM_ASSERT is used in data structure headers which led to including graphics and windowing APIs in data structure modules. --- src/Debugging.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/Debugging.h (limited to 'src/Debugging.h') diff --git a/src/Debugging.h b/src/Debugging.h new file mode 100644 index 000000000..b7ea20b98 --- /dev/null +++ b/src/Debugging.h @@ -0,0 +1,44 @@ +// Scintilla source code edit control +/** @file Debugging.h + ** Assert and debug trace functions. + ** Implemented in each platform layer. + **/ +// Copyright 1998-2009 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#ifndef DEBUGGING_H +#define DEBUGGING_H + +namespace Scintilla { + +#if defined(__clang__) +# if __has_feature(attribute_analyzer_noreturn) +# define CLANG_ANALYZER_NORETURN __attribute__((analyzer_noreturn)) +# else +# define CLANG_ANALYZER_NORETURN +# endif +#else +# define CLANG_ANALYZER_NORETURN +#endif + +/** + * Platform namespace used to segregate debugging functions. + */ +namespace Platform { + +void DebugDisplay(const char *s) noexcept; +void DebugPrintf(const char *format, ...) noexcept; +bool ShowAssertionPopUps(bool assertionPopUps_) noexcept; +void Assert(const char *c, const char *file, int line) noexcept CLANG_ANALYZER_NORETURN; + +} + +#ifdef NDEBUG +#define PLATFORM_ASSERT(c) ((void)0) +#else +#define PLATFORM_ASSERT(c) ((c) ? (void)(0) : Scintilla::Platform::Assert(#c, __FILE__, __LINE__)) +#endif + +} + +#endif -- cgit v1.2.3