Macros
assert.h File Reference

Defines macros used for assertions. More...

#include <iostream>
#include <cstdlib>
+ Include dependency graph for assert.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define _BASIS_ASSERT_H
 
#define assert(condition)
 Assertion without custom message. More...
 
#define ASSERT(condition, message)
 Assertion with custom message. More...
 

Detailed Description

Defines macros used for assertions.

Definition in file assert.h.

Macro Definition Documentation

§ _BASIS_ASSERT_H

#define _BASIS_ASSERT_H

Definition at line 17 of file assert.h.

§ assert

#define assert (   condition)
Value:
do { \
if (!(condition)) { \
::std::cerr << "Assertion `" #condition "` failed in " << __FILE__ \
<< " line " << __LINE__ << ::std::endl; \
::std::exit(EXIT_FAILURE); \
} \
} while (false)
cmake __FILE__
Absolute path of script file.

Assertion without custom message.

The assertion is only checked if NDEBUG is defined.

Example:

assert(x > 0);

Definition at line 44 of file assert.h.

§ ASSERT

#define ASSERT (   condition,
  message 
)
Value:
do { \
if (!(condition)) { \
::std::cerr << "Assertion `" #condition "` failed in " << __FILE__ \
<< " line " << __LINE__ << ": " << message << ::std::endl; \
::std::exit(EXIT_FAILURE); \
} \
} while (false)
cmake __FILE__
Absolute path of script file.

Assertion with custom message.

The assertion is only checked if NDEBUG is defined.

Example:

ASSERT(x > 0, "Actual value of x is " << x);
See also
http://stackoverflow.com/questions/3767869/adding-message-to-assert

Definition at line 70 of file assert.h.