common.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00037 #ifndef ADCHPP_COMMON_H
00038 #define ADCHPP_COMMON_H
00039
00040 namespace adchpp {
00041
00042 extern ADCHPP_DLL const char compileTime[];
00043 extern ADCHPP_DLL void logAssert(const char* file, int line, const char* exp);
00044
00045 #ifndef NDEBUG
00046
00047 inline void debugTrace(const char* format, ...)
00048 {
00049 va_list args;
00050 va_start(args, format);
00051
00052 #ifdef _MSC_VER
00053 char buf[512];
00054
00055 _vsnprintf(buf, sizeof(buf), format, args);
00056 OutputDebugStringA(buf);
00057 fputs(buf, stderr);
00058 #else // _MSC_VER
00059 vfprintf(stdout, format, args);
00060 #endif // _MSC_VER
00061 va_end(args);
00062 }
00063
00064 #define dcdebug debugTrace
00065 #define dcassert(exp) do { if(!(exp)) logAssert(__FILE__, __LINE__, #exp); } while(false)
00066
00067
00068 #define dcasserta(exp) dcassert(exp)
00069 #define dcdrun(exp) exp
00070 #else //NDEBUG
00071 #define dcdebug if(false) printf
00072
00073 #define dcassert(exp)
00074 #ifdef _MSC_VER
00075 #define dcasserta(exp) __assume(exp)
00076 #else
00077 #define dcasserta(exp)
00078 #endif // WIN32
00079 #define dcdrun(exp)
00080 #endif //NDEBUG
00081
00082
00083 #ifdef min
00084 #undef min
00085 #endif
00086 #ifdef max
00087 #undef max
00088 #endif
00089
00090 typedef std::vector<std::string> StringList;
00091 typedef StringList::iterator StringIter;
00092 typedef StringList::const_iterator StringIterC;
00093
00094 typedef std::vector<uint8_t> ByteVector;
00095 typedef ByteVector::iterator ByteIter;
00096
00100 ADCHPP_DLL void initialize(const std::string& path);
00101
00105 ADCHPP_DLL void startup(void (*f)());
00106
00110 ADCHPP_DLL void shutdown(void (*f)());
00111
00115 ADCHPP_DLL void cleanup();
00116
00117 }
00118
00119 #endif // COMMON_H