myassert.h
来自「跨操作系统的微型中间件」· C头文件 代码 · 共 66 行
H
66 行
#ifndef _MYASSERT_H_#define _MYASSERT_H_#include <stdio.h>
#include <assert.h>
#ifdef __cplusplus
extern "C" {
#endif
#if ASSERT #define Assert(condition) { \ if (!(condition)) \ { \ printf("_Assert: %s, %d",__FILE__, __LINE__ ); \ } \
assert(condition); } #define AssertV(condition,errNo) { \ if (!(condition)) \ { \ printf("_AssertV: %s, %d (%d)",__FILE__, __LINE__, errNo ); \ }
#define AssertV2(condition,msg) { \
if (!(condition)) \
{ \
printf("_AssertV: %s, %d (%s)",__FILE__, __LINE__, msg ); \
} \
assert(condition); }
#define Warn(condition) { \ if (!(condition)) \ printf( "_Warn: %s, %d\n",__FILE__, __LINE__ ); } #define WarnV(condition,msg) { \ if (!(condition)) \ printf ("_WarnV: %s, %d (%s)\n",__FILE__, __LINE__, msg ); } #define WarnVE(condition,msg,err) { \ if (!(condition)) \ { char buffer[kAssertBuffSize]; \ buffer[kAssertBuffSize -1] = 0; \ printf ("_WarnV: %s, %d (%s, %s [err=%d])\n",__FILE__, __LINE__, msg, qtss_strerror(err,buffer,sizeof(buffer) -1), err ); \ } }#else #define Assert(condition) ((void) 0) #define AssertV(condition,errNo) ((void) 0) #define Warn(condition) ((void) 0) #define WarnV(condition,msg) ((void) 0)#endif
#ifdef __cplusplus
}
#endif
#endif //_MY_ASSERT_H_
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?