Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

# Platform/Aperios1.3.2/GTAssert.h

Go to the documentation of this file.

    00001 /**
    00002  * @file Platform/Aperios1.3.2/GTAssert.h
    00003  *
    00004  * This file contains macros for low level debugging.
    00005  *
    00006  * @author Thomas Röfer
    00007  */
    00008
    00009 #ifndef __GTAssert_h_
    00010 #define __GTAssert_h_
    00011
    00012 #include <stdio.h>
    00013
    00014 #ifdef min
    00015 #undef min
    00016 #endif
    00017 #ifdef max
    00018 #undef max
    00019 #endif
    00020 #include <iostream.h>
    00021
    00022 #ifdef NDEBUG
    00023 #define ASSERT(cond) ((void)0)
    00024 #define VERIFY(cond) ((void)(cond))
    00025 #define PRINT(text) ((void)0)
    00026
    00027 #else
    00028
    00029 /**
    00030  * ASSERT prints a message if cond is false and NDEBUG is not defined.
    00031  * ASSERT does not evaluate cond if NDEBUG is defined.
    00032  * Note that printf will not work in early stages of the creation of an Aperios
    00033  * process. Therefore, you will not get any feedback in such a case. If you are
    00034  * not sure whether an assertion failure will be reported at a certain position
    00035  * in the code, try ASSERT(false).
    00036  * @param cond The condition to be checked.
    00037  */
    00038 #define ASSERT(cond) {if(!(cond)) ::printf("ASSERT(" #cond ") failed in line %d of file " \
    00039   __FILE__ ".\n",__LINE__);}
    00040
    00041 /**
    00042  * VERIFY prints a message if cond is false and NDEBUG is not defined.
    00043  * VERIFY does evaluate cond even if NDEBUG is defined.
    00044  * Note that printf will not work in early stages of the creation of an Aperios
    00045  * process. Therefore, you will not get any feedback in such a case. If you are
    00046  * not sure whether an assertion failure will be reported at a certain position
    00047  * in the code, try ASSERT(false).
    00048  * @param cond The condition to be checked.
    00049  */
    00050 #define VERIFY(cond) {if(!(cond)) ::printf("VERIFY(" #cond ") failed in line %d of file " \
    00051   __FILE__ ".\n",__LINE__);}
    00052
    00053 /**
    00054  * PRINT prints a text directly to the output if and NDEBUG is not defined.
    00055  * PRINT does not evaluate the parameter if NDEBUG is defined.
    00056  * @param text The text that will be printed.
    00057  */
    00058 #define PRINT(text) {cout << text << "\n"; cout.flush();}
    00059
    00060 #endif
    00061
    00062 #endif // __GTAssert_h_