BASIS  r3148
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.

Defines

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

Detailed Description

Defines macros used for assertions.

Copyright (c) 2011, 2012 University of Pennsylvania. All rights reserved.
See https://www.cbica.upenn.edu/sbia/software/license.html or COPYING file.

Contact: SBIA Group <sbia-software at uphs.upenn.edu>

Definition in file assert.h.


Define Documentation

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

Assertion without custom message.

The assertion is only checked if NDEBUG is defined.

Example:

 assert(x > 0);

Definition at line 40 of file assert.h.

#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)

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 66 of file assert.h.