Skip to content
This repository has been archived by the owner on Jan 22, 2024. It is now read-only.

8ightfold/efl-assert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

efl-assert

DEPRECATED, use efl::core's $raw_assert(...).

This library's purpose is simple: it extends assert. It allows you to swap this:

assert(cond && "Message");

with this:

EflAssert(cond, "Message");

It does this by locating assert.h, extracting the debug definition, and then replacing the default stringification with a custom message.

To get started, just do:

add_subdirectory(efl-assert)
...
target_link_libraries(your-exe efl::assert)

Dependencies

efl::assert has to parse assert.h, so a scripting language is required. Because of this, you need Perl installed and configured for CMake usage.

If you set EFL_ASSERT_FALLBACK to ON, the fallback path will immediately be taken (though this does defeat the purpose of the library).

C++ Usage

<efl/Assert.hpp> defines a few things:

#define EflAssert(check, message) ...
#define EflDynAssert(check, to-format...) \
    EflAssert(check, EflDynAssertFormatter(to-format))
#define EflDynAssertFormatter(to-format...) ...

#define EflDbgAssert(check, message)
#define EflDbgDynAssert(check, to-format...)

EflAssert is like normal assert, except a custom message is printed as the error.

EflDynAssert will pass its arguments to EflDynAssertFormatter, which get converted into a local string. You can provide your own definition for the formatting, just make sure it evaluates to a const char*, or something that can be implicitly converted to it.

The Dbg variants of both functions work the same in debug mode, but if NDEBUG is defined, they become noops.

About

Simple assertion library for C++11

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published