Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
a6707422
"vscode:/vscode.git/clone" did not exist on "90e753c97ab4fb8920fe6ddc4a3dc0572a097b47"
Commit
a6707422
authored
Aug 28, 2016
by
Davis King
Browse files
Made the message argument of the DLIB_ASSERT and DLIB_CASSERT macros optional.
parent
3f92a5cf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
dlib/assert.h
dlib/assert.h
+11
-3
No files found.
dlib/assert.h
View file @
a6707422
...
@@ -135,7 +135,7 @@ namespace dlib
...
@@ -135,7 +135,7 @@ namespace dlib
#define DLIB_FUNCTION_NAME "unknown function"
#define DLIB_FUNCTION_NAME "unknown function"
#endif
#endif
#define DLIB_CASSERT(_exp,_message) \
#define DLIB
M
_CASSERT(_exp,_message) \
{if ( !(_exp) ) \
{if ( !(_exp) ) \
{ \
{ \
dlib_assert_breakpoint(); \
dlib_assert_breakpoint(); \
...
@@ -148,12 +148,20 @@ namespace dlib
...
@@ -148,12 +148,20 @@ namespace dlib
throw dlib::fatal_error(dlib::EBROKEN_ASSERT,dlib_o_out.str()); \
throw dlib::fatal_error(dlib::EBROKEN_ASSERT,dlib_o_out.str()); \
}}
}}
// Make it so the 2nd argument of DLIB_CASSERT is optional. That is, you can call it like
// DLIB_CASSERT(exp) or DLIB_CASSERT(exp,message).
#define DLIBM_CASSERT_1_ARGS(exp) DLIBM_CASSERT(exp,"")
#define DLIBM_CASSERT_2_ARGS(exp,message) DLIBM_CASSERT(exp,message)
#define DLIBM_GET_3TH_ARG(arg1, arg2, arg3, ...) arg3
#define DLIBM_CASSERT_CHOOSER(...) DLIBM_GET_3TH_ARG(__VA_ARGS__, DLIBM_CASSERT_2_ARGS, DLIBM_CASSERT_1_ARGS)
#define DLIB_CASSERT(...) DLIBM_CASSERT_CHOOSER(__VA_ARGS__)(__VA_ARGS__)
#ifdef ENABLE_ASSERTS
#ifdef ENABLE_ASSERTS
#define DLIB_ASSERT(
_exp,_message
) DLIB_CASSERT(_
exp,_message
)
#define DLIB_ASSERT(
...
) DLIB_CASSERT(_
_VA_ARGS__
)
#define DLIB_IF_ASSERT(exp) exp
#define DLIB_IF_ASSERT(exp) exp
#else
#else
#define DLIB_ASSERT(
_exp,_message
) {}
#define DLIB_ASSERT(
...
) {}
#define DLIB_IF_ASSERT(exp)
#define DLIB_IF_ASSERT(exp)
#endif
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment