【发布时间】:2015-06-24 00:22:43
【问题描述】:
在 C# 中,我们可以使用 #warning 在错误窗口中显示警告。
在 Visual C++ 中,#pragma message 类似,但它只是输出消息而不是警告。
在 C++(Windows、Visual Studio、MSVC)中,有没有办法故意向用户显示警告?
我试过#warning DEBUG is definedwhich works in some other compilers,但不是MSVC。
它给了我这个错误:
错误 C1021:无效的预处理器命令“警告”AecProject stdafx.h 49
【问题讨论】:
-
James McNellis 在这里为 MSVC 中的警告提供了出色的解决方案,捎带
#pragma message并匹配编译器的内部标准化警告格式:stackoverflow.com/a/2706693/366904
标签: c++ visual-c++ c-preprocessor warnings