00001 #ifndef _FV_ASSERT_H_
00002 #define _FV_ASSERT_H_
00003
00004 #include <stdio.h>
00005 #include "fv_config.h"
00006 #include "defs.h"
00007
00008
00009 #ifdef FV_DEBUG
00010 #include <signal.h>
00011
00012
00013 #ifndef WIN32
00014 # define fv_assert(Condition,file,line) { \
00015 bool Cond = Condition; \
00016 if(!Cond){ \
00017 fprintf(stderr,"ASSERTION: %s feild in %s, line %d\n",FV_STR(Condition),file,line); \
00018 ::raise(SIGSEGV); \
00019 } \
00020 }
00021
00022 # else
00023 # define WINDOWS_LEAN_AND_MEAN
00024 #include <windows.h>
00025 inline void fv_assert(bool Condition, const char* file, const int line)
00026 {
00027 if(!Condition) {
00028 wchar_t buf[1024];
00029 LPTSTR pbuf = (LPTSTR)buf;
00030 wsprintf(pbuf,TEXT("Assertion failed in file: %s line: %d"),file,line);
00031 MessageBox(0,pbuf,TEXT("Error!"),MB_ICONSTOP);
00032 exit(EXIT_FAILURE);
00033 }
00034 }
00035 #endif
00036
00037 #define FV_ASSERT(Condition) fv_assert(Condition,__FILE__,__LINE__)
00038
00039 #else
00040 #define FV_ASSERT(Condition)
00041 #endif // Fv_DEBUF
00042
00043
00044
00045
00046
00047 #endif // _FD_ASSERT_H_