如何用vs编译c语言,compiler error C1853

这里犯得错误是使用c++的预编译头去编译c语言。

如果解决C1853这个错误呢?

其实就是对每一个.c文件加上

#include "stdafx.h"

然后把.c文件改为.cpp文件

然后在把工程属性中的

configuration properties中的c/c++中的Precompiled Header中的Create / use Precompile Header 中的User precompile Header 改为

Create precompile Header

 

How to compile C programs with Microsoft Visual C++ 2005

 

By default, new applications created in Microsoft Visual C++ 2005 Express edition create C++ source code.

Here is how to compile C code. Launch Visual C++ 2005 Express Edition and create a new project. Choose Win 32 and Win 32 Console Application. Enter a name in the Name box below.

Now press the Next button and then the Finish button. This will generate a file called name.cpp where name is your entered project name. Now look to the Solution Explorer (if you can't see it, click View on the menu then Solution Explorer), click name.cpp and press F2. Now press backspace twice so you end up with name.c.

Press F7 To compile. If you get an error that say "fatal error C1853: 'Debug/name.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)" then just click the project menu, properties and change Create/Use Precompiled Header from Use Precompiled Header to Create Precompoiled Header. Press the Apply button. It should now compile successfully when you press F7.

Using Existing Code

Create an empty project as above and remove all lines except
#include "stdafx.h"
Then paste in your existing code after this include and save it. You should now be able to compile (press F7) and run your application.
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值