assert.h
Go to the documentation of this file.00001 #ifndef _ASSERT_H
00002 #define _ASSERT_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 FILE_LICENCE ( GPL2_OR_LATER );
00014
00015 #ifdef NDEBUG
00016 #define ASSERTING 0
00017 #else
00018 #define ASSERTING 1
00019 #endif
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 extern int __attribute__ (( format ( printf, 1, 2 ) ))
00032 assert_printf ( const char *fmt, ... ) asm ( "printf" );
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #define assert( condition ) \
00044 do { \
00045 if ( ASSERTING && ! (condition) ) { \
00046 assert_printf ( "assert(%s) failed at %s line %d\n", \
00047 #condition, __FILE__, __LINE__ ); \
00048 } \
00049 } while ( 0 )
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 #define linker_assert( condition, error_symbol ) \
00062 if ( ! (condition) ) { \
00063 extern void error_symbol ( void ); \
00064 error_symbol(); \
00065 }
00066
00067 #endif