关于c/c++的#error, 自己用得不多, 一般在编译的时候才会用, 写个代码demo来看看:

#define xyz "just for test"
#ifdef xyz
#error "wrong"
#endif

#include <iostream>
using namespace std;

int main()
{
	cout << "main" << endl;
	return 0;
}
      出现预期中的编译错误:

C:\Documents and Settings\Administrator\桌面\cpp\test\main.cpp(3) : fatal error C1189: #error :  "wrong"


      #error有时还挺有用的, 主要是提醒程序猿, 其实是强迫程序猿来修改对应的问题。






本文转载:CSDN博客