我是靠谱客的博主 飞快舞蹈,这篇文章主要介绍C/C++的#error,现在分享给大家,希望可以做个参考。

       关于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 SettingsAdministrator桌面cpptestmain.cpp(3) : fatal error C1189: #error :  "wrong"


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





最后

以上就是飞快舞蹈最近收集整理的关于C/C++的#error的全部内容,更多相关C/C++内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(112)

评论列表共有 0 条评论

立即
投稿
返回
顶部