静态断言assert

#define NDEBUG
#define _CRT_SECURE_NO_WARNINGS
#include
#include
#include
#include
#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");
}

你可能感兴趣的:(C程序设计语言笔记)