在遇到用户创建的错误后,如何以编程方式强制编译器停止编译过程? [英] How can I programmatically force the compiler to stop the compilation process after it encountered a user created error?
问题描述
在我的代码中,我正在使用 #error
预处理程序指令来创建错误。但是,它仍然继续构建过程。
In my code I am using the #error
preprocessor directive in order to create an error. However, it still continues the building process.
遇到错误后,如何强制以编程方式强制构建过程停止?
How can I force the building process programmatically to stop after encountering my error?
我正在使用Windows 10的Microsoft Visual Studio 2015,C ++ v140,x86。
I am using Microsoft Visual Studio 2015, C++ v140, x86, for Windows 10.
推荐答案
#error指令在编译时发出用户指定的错误消息 ,然后终止编译。
The #error directive emits a user-specified error message at compile time and then terminates the compilation.
(已添加强调)
如果在 #error
指令后编译仍在继续,则说明您做的很奇怪,否则MSVC被破坏了。
If compilation is continuing after the #error
directive, then you're doing something odd, or MSVC is broken.
这篇关于在遇到用户创建的错误后,如何以编程方式强制编译器停止编译过程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!