This commit is contained in:
Your Name 2025-04-28 22:03:12 +12:00
parent 320fd1f3f0
commit ff43e4122a
3 changed files with 10 additions and 32 deletions

View File

@ -74,8 +74,8 @@ fi
# Configure with CMake # Configure with CMake
print_status "Configuring with CMake..." print_status "Configuring with CMake..."
cmake .. -DCMAKE_BUILD_TYPE=Debug #cmake .. -DCMAKE_BUILD_TYPE=Debug
#cmake .. -DCMAKE_BUILD_TYPE=Release cmake .. -DCMAKE_BUILD_TYPE=Release
# Build the project # Build the project
print_status "Building project..." print_status "Building project..."

View File

@ -87,6 +87,7 @@ std::string safearg(int argc, char *argv[], int index)
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
if (safearg(argc,argv,1) == "hash") return dropshell::hash_demo_raw(safearg(argc,argv,2)); if (safearg(argc,argv,1) == "hash") return dropshell::hash_demo_raw(safearg(argc,argv,2));
ASSERT_MSG(safearg(argc,argv,1) != "assert", "Hello! Here is an assert.");
try { try {
// silently attempt to load the config file. // silently attempt to load the config file.
@ -180,8 +181,8 @@ int main(int argc, char* argv[]) {
} }
if (cmd == "edit" && argc < 4) { if (cmd == "edit" && argc < 4) {
ASSERT_ALWAYS(argc>=3); ASSERT_MSG(argc>=3, "Error: logic error!");
dropshell::edit_server(argv[2]); dropshell::edit_server(safearg(argc,argv,2));
return 0; return 0;
} }

View File

@ -39,39 +39,16 @@ struct SourceLocation {
} // namespace ds } // namespace ds
// Define assertion macros with different behaviors based on build configuration // Standard assertion
#if defined(NDEBUG) && !defined(DS_ENABLE_RELEASE_ASSERTS) #define ASSERT(condition) \
// Assertions disabled in release builds by default
#define ASSERT(condition) ((void)0)
#define ASSERT_MSG(condition, message) ((void)0)
#else
// Standard assertion
#define ASSERT(condition) \
do { \
if (!(condition)) { \
ds::assert_fail(#condition, DS_CURRENT_LOCATION); \
} \
} while (false)
// Assertion with custom message
#define ASSERT_MSG(condition, message) \
do { \
if (!(condition)) { \
ds::assert_fail(#condition, DS_CURRENT_LOCATION, message); \
} \
} while (false)
#endif
// Always-active assertion for critical checks, even in release builds
#define ASSERT_ALWAYS(condition) \
do { \ do { \
if (!(condition)) { \ if (!(condition)) { \
ds::assert_fail(#condition, DS_CURRENT_LOCATION); \ ds::assert_fail(#condition, DS_CURRENT_LOCATION); \
} \ } \
} while (false) } while (false)
// Always-active assertion with custom message for critical checks // Assertion with custom message
#define ASSERT_ALWAYS_MSG(condition, message) \ #define ASSERT_MSG(condition, message) \
do { \ do { \
if (!(condition)) { \ if (!(condition)) { \
ds::assert_fail(#condition, DS_CURRENT_LOCATION, message); \ ds::assert_fail(#condition, DS_CURRENT_LOCATION, message); \