运行c ++程序时vc ++中的致命错误

时间:2016-09-09 13:58:55

标签: c++ visual-c++

我是vc ++的新手。

#include<iostream.h>

void main()
{
    cout<<"hi this is vc++";
}
  

...编译

     

h.cpp

     

c:\ program files \ microsoft visual studio \ myprojects \ new1 \ h.cpp(7):   致命错误C1010:寻找时意外结束文件   precompiled header directive执行cl.exe时出错。

     

h.obj - 1个错误,0个警告

1 个答案:

答案 0 :(得分:1)

Visual C ++默认使用预编译的头文件,这个功能加快了编译速度,但这意味着你需要有一个#include&#34; stdafx.h&#34;在你的cpp文件的顶部。

另一种方法是关闭预编译的头文件。以下是如何操作(source and more detail here):

  

在Visual Studio 2010中,通过右键单击CPP项目,从GUI控制此设置,选择&#39;属性&#39;并导航到&#34;配置属性\ C / C ++ \预编译标题&#34;。对于其他版本的Visual Studio,GUI中的位置将不同。

相关问题