Go to the documentation of this file.00001
00006 #ifndef __CHECK_H__
00007 #define __CHECK_H__
00008
00009 #include <stdarg.h>
00010 #include <stdio.h>
00011 #include <stdlib.h>
00012
00013 static void
00014 check_impl (int condition,
00015 const char * file,
00016 int line,
00017 const char * format, ...)
00018 {
00019 va_list args;
00020 va_start(args, format) ;
00021 if (! condition) {
00022 fprintf(stderr, "%s:%d: check failed: ", file, line) ;
00023 vfprintf(stderr, format, args) ;
00024 fprintf(stderr, "\n") ;
00025 exit (1) ;
00026 }
00027 va_end(args) ;
00028 }
00029
00030 #define check(condition, ...) \
00031 check_impl(condition, __FILE__, __LINE__, "" __VA_ARGS__)
00032
00033 #define check_signoff() \
00034 fprintf(stdout, "%s passed\n", __FILE__)
00035
00036
00037 #endif