静态断言assert

来源:互联网 发布:影视行业 知乎 编辑:程序博客网 时间:2024/06/01 10:27
#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); \}#endifint main(){int num = 10;num = 21;myassert(num < 20);printf("%d", num);system("pause");}

0 0
原创粉丝点击