visual-studio C++ Visual Studio 编译错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/494064/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 10:06:59  来源:igfitidea点击:

C++ Visual Studio Compilation error

c++visual-studio

提问by Michael Burr

I get the following compilation error

我收到以下编译错误

fatal error C1189: #error : ERROR: Use of C runtime library internal header file.

致命错误 C1189:#error:错误:使用 C 运行时库内部头文件。

I absolutely have no idea about it. can anyone throw some light on it?

我完全不知道。任何人都可以对此有所了解吗?

The complete error:

完整的错误:

C:\Program Files\Microsoft Visual Studio 8\VC\ce\include\crtdefs.h(100) : fatal error C1189: #error : ERROR: Use of C runtime library internal header file. Generating Code...

C:\Program Files\Microsoft Visual Studio 8\VC\ce\include\crtdefs.h(100):致命错误 C1189:#error:错误:使用 C 运行时库内部头文件。正在生成代码...

回答by Michael Burr

You've probably got crt/srcin your include directory search path. The headers in there are used to build the C Runtime - they aren't intended for use in user programs (even though they may have the same names as files that are intended to be included).

您可能已经crt/src进入包含目录搜索路径。那里的头文件用于构建 C 运行时 - 它们不打算用于用户程序(即使它们可能与打算包含的文件具有相同的名称)。

If you look in the header that's causing the problem, you'll probably see something like this:

如果您查看导致问题的标题,您可能会看到如下内容:

/* This version of the header files is NOT for user programs.
 * It is intended for use when building the C runtimes ONLY.
 * The version intended for public use will not have this message.
 */

You need to fix your include search path.

您需要修复包含搜索路径。

I see you have ce/includein your include search path - are you building a WinCE application? If so, your build should be defining _WIN32_WCEto prevent this problem. If not, this directory should not be in the include path.

我看到您ce/include的包含搜索路径中有 - 您正在构建 WinCE 应用程序吗?如果是这样,您的构建应该定义_WIN32_WCE以防止出现此问题。如果不是,则此目录不应位于包含路径中。

回答by Julien

To add a bit of precision, in my case I just needed to change the Include path of one of the .h files I used as shown below.

为了增加一点精度,在我的情况下,我只需要更改我使用的其中一个 .h 文件的包含路径,如下所示。

I started with this Include path :

我从这个包含路径开始:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\crt\src

and then changed it to:

然后将其更改为:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include

which is where the right header file was located.

这是正确的头文件所在的位置。