1
0
Fork 0

Fix: asserts unintentially being partially disabled in release-builds (#11268)

The nlohmann-json header file includes assert.h, which rudely resets
the assert macro to what that header thinks is right. As we set the
assert macro to be active with release builds when WITH_ASSERT is
active, this means that every file including nlohmann-json has their
asserts disabled (for release-builds) but files that don't do no.

Let's avoid this issue, by telling nlohmann to not include assert.h.
pull/11273/head
Patric Stout 2023-09-08 12:11:37 +02:00 committed by GitHub
parent 8c742b456f
commit d725fa14a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -394,6 +394,10 @@ void NORETURN AssertFailedError(int line, const char *file, const char *expressi
# define assert(expression) if (unlikely(!(expression))) AssertFailedError(__LINE__, __FILE__, #expression);
#endif
/* Define JSON_ASSERT, which is used by nlohmann-json. Otherwise the header-file
* will re-include assert.h, and reset the assert macro. */
#define JSON_ASSERT(x) assert(x)
#if defined(MAX_PATH)
/* It's already defined, no need to override */
#elif defined(PATH_MAX) && PATH_MAX > 0