Skip to content

Commit

Permalink
Fix C++20 compiler error when CESIUM_FORCE_ASSERTIONS is not defined.
Browse files Browse the repository at this point in the history
  • Loading branch information
kring committed Nov 6, 2024
1 parent 89dfc44 commit 9c61641
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CesiumUtility/include/CesiumUtility/Assert.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#pragma once

#include <cstdint>

//
// Define our own assertion, so that users can forcebly turn them on if needed
//
#if defined CESIUM_FORCE_ASSERTIONS && defined NDEBUG
// Asserts are defined in cassert and normally compiled out when NDEBUG is
// defined. Redirect to our own assertion that can't be compiled out
namespace CesiumUtility {
void forceAssertFailure();
std::int32_t forceAssertFailure();
};
#define CESIUM_ASSERT(expression) \
((expression) ? 0 : CesiumUtility::forceAssertFailure())
Expand Down
5 changes: 4 additions & 1 deletion CesiumUtility/src/Assert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
#define NDEBUG

namespace CesiumUtility {
void forceAssertFailure() { assert(0 && "Assertion failed"); }
std::int32_t forceAssertFailure() {
assert(0 && "Assertion failed");
return 1;
}
}; // namespace CesiumUtility

#endif

0 comments on commit 9c61641

Please sign in to comment.