【问题标题】:Precompile header in CPP project and C generated from wsdl fileCPP 项目中的预编译头文件和从 wsdl 文件生成的 C
【发布时间】:2015-03-24 19:28:54
【问题描述】:

我正在 CPP 中创建简单的 Web 服务客户端。我在 svcutil ans wsutil utilites 的帮助下从 WSDL 生成了源文件。最后我得到了 Web 服务接口 headerC 文件。

当我将 C 文件包含到使用预编译标头的控制台应用程序中时,我收到消息:

Error   3   error C1853: 'Debug\TestLib3.pch' precompiled header file is from a previous version of the compiler, or the precompiled header is C++ and you are using it from C (or vice versa)  

如何解决这个问题?

【问题讨论】:

    标签: c++ visual-c++ svcutil.exe


    【解决方案1】:

    C 编译器不能使用由 C++ 编译器生成的 .pch 文件。两个基本选项:

    • 将 .c 文件重命名为 .cpp,可能在自动生成的源文件上工作正常。

    • 右键单击解决方案资源管理器窗口中的 .c 文件,属性,C/C++,预编译头,“预编译头”选项。将其更改为“不使用”。您可能还需要修改#includes .h 文件的C++ 源文件,它可能需要在#include 指令周围使用extern "C" {},以便C++ 编译器知道.h 文件包含C 声明。当您收到显示函数名称错误的链接器错误时,您就会知道这是必需的。

    【讨论】:

      猜你喜欢
      • 2012-12-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-09
      相关资源
      最近更新 更多