在遇到用户创建的错误后,如何以编程方式强制编译器停止编译过程? [英] How can I programmatically force the compiler to stop the compilation process after it encountered a user created error?

查看:99
本文介绍了在遇到用户创建的错误后,如何以编程方式强制编译器停止编译过程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的代码中,我正在使用 #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.

推荐答案

来自MSDN


#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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆