#define NDEBUG
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
#include<Windows.h>
#ifndef NDEBUG
#define myassert(x)
#else
#define myassert(x) \
if (!(x))\
{\
printf("myassert(%s)宏检测开始。。。。\n", #x); \
printf("出错文件名%s,函数名%s,行号%d", __FUNCTION__, __FILE__, __LINE__); \
char str[50]; \
sprintf(str, "出错文件名%s,函数名%s,行号%d", __FUNCTION__, __FILE__, __LINE__); \
MessageBoxA(0,str,"小伙你的程序出错了",0); \
}
#endif
int main()
{
int num = 10;
num = 21;
myassert(num < 20);
printf("%d", num);
system("pause");
}
静态断言assert
最新推荐文章于 2023-02-21 23:15:48 发布