diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f2a972..a8390d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,8 +16,8 @@ if (SQLITE_ENABLE_COLUMN_METADATA) add_definitions(-DSQLITE_ENABLE_COLUMN_METADATA) endif() +# Enable the user defintion of a assertion_failed() handler. add_definitions(-DSQLITECPP_ENABLE_ASSERT_HANDLER) - if (MSVC) # build the SQLite3 C library for Windows (for ease of use) diff --git a/README.md b/README.md index 833efe6..c50a5be 100644 --- a/README.md +++ b/README.md @@ -217,7 +217,7 @@ namespace SQLite void assertion_failed(const char* apFile, const long apLine, const char* apFunc, const char* apExpr, const char* apMsg) { // Print a message to the standard error output stream, and abort the program. - std::cerr << apFile << ":" << apLine << ":" << " error: assertion (" << apExpr << ") failed in '" << apFunc << "' (" << apMsg << ")\n"; + std::cerr << apFile << ":" << apLine << ":" << " error: assertion failed (" << apExpr << ") in " << apFunc << "() with message \"" << apMsg << "\"\n"; std::abort(); } } diff --git a/examples/example1/main.cpp b/examples/example1/main.cpp index 5ce6a87..1e1745a 100644 --- a/examples/example1/main.cpp +++ b/examples/example1/main.cpp @@ -11,8 +11,8 @@ */ #include -#include -#include +#include +#include #include @@ -25,7 +25,7 @@ namespace SQLite void assertion_failed(const char* apFile, const long apLine, const char* apFunc, const char* apExpr, const char* apMsg) { // Print a message to the standard error output stream, and abort the program. - std::cerr << apFile << ":" << apLine << ":" << " error: assertion (" << apExpr << ") failed in " << apFunc << ": '" << apMsg << "'\n"; + std::cerr << apFile << ":" << apLine << ":" << " error: assertion failed (" << apExpr << ") in " << apFunc << "() with message \"" << apMsg << "\"\n"; std::abort(); } } diff --git a/src/Assert.h b/src/Assertion.h similarity index 85% rename from src/Assert.h rename to src/Assertion.h index 984902d..a4256cd 100644 --- a/src/Assert.h +++ b/src/Assertion.h @@ -1,5 +1,5 @@ /** - * @file Assert.h + * @file Assertion.h * @ingroup SQLiteCpp * @brief Definition of the SQLITECPP_ASSERT() macro. * @@ -39,14 +39,8 @@ namespace SQLite #else // if no assert handler provided by user code, use standard assert() - -#ifndef NDEBUG - // in debug mode, assert() : - #define SQLITECPP_ASSERT(expression,message) assert(expression) -#else - // in release mode, nothing : - #define SQLITECPP_ASSERT(expression,message) (expression) -#endif +// (note: in debug mode, assert() does nothing) +#define SQLITECPP_ASSERT(expression,message) assert(expression && message) #endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7e88c42..3fa7916 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,7 +12,7 @@ # add sources of the wrapper as a "SQLiteCpp" static library add_library (SQLiteCpp SQLiteC++.h - Assert.h + Assertion.h Column.cpp Column.h Database.cpp diff --git a/src/Database.cpp b/src/Database.cpp index ec18057..043a6b0 100644 --- a/src/Database.cpp +++ b/src/Database.cpp @@ -11,7 +11,7 @@ #include "Database.h" #include "Statement.h" -#include "Assert.h" +#include "Assertion.h" #include "Exception.h" diff --git a/src/SQLiteC++.h b/src/SQLiteC++.h index 8aa3763..1ea36f9 100644 --- a/src/SQLiteC++.h +++ b/src/SQLiteC++.h @@ -18,7 +18,7 @@ // Include useful headers of SQLiteC++ -#include "Assert.h" +#include "Assertion.h" #include "Exception.h" #include "Database.h" #include "Statement.h" diff --git a/src/Statement.cpp b/src/Statement.cpp index 72c9d7c..24ac1fb 100644 --- a/src/Statement.cpp +++ b/src/Statement.cpp @@ -12,7 +12,7 @@ #include "Database.h" #include "Column.h" -#include "Assert.h" +#include "Assertion.h" #include "Exception.h" diff --git a/src/Transaction.cpp b/src/Transaction.cpp index 827fe83..3b22bf3 100644 --- a/src/Transaction.cpp +++ b/src/Transaction.cpp @@ -11,7 +11,7 @@ #include "Transaction.h" #include "Database.h" -#include "Assert.h" +#include "Assertion.h" #include "Exception.h"