我正在使用Microsoft Visual Studio Express 2013并编写了以下代码
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world!";
return 0;
}
我收到以下错误
1智能感知:PCH警告:找不到合适的标头停止位置。未生成IntelliSense PCH文件。
2智能感知:预期宣言 错误3错误C1010:查找预编译头时意外结束文件。你忘了在你的来源添加'#include“stdafx.h”'吗?
我尝试添加'#include“stdafx.h”但这没有区别。我已经预编译了标题,如果我取消它,我会在尝试构建时收到以下消息。
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Users\Justin\Desktop\ConsoleApplication6\Debug\ConsoleApplication6.exe'. Symbols loaded.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp120d.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr120d.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\guard32.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\user32.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\gdi32.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\lpk.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\usp10.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcrt.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\advapi32.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sechost.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sspicli.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptbase.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\version.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\imm32.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msctf.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\fltLib.dll'. Cannot find or open the PDB file.
The program '[4872] ConsoleApplication6.exe' has exited with code 0 (0x0).
答案 0 :(得分:5)
stdafx.h
的问题最好通过不使用预编译的标头来解决,您不需要它们用于测试程序。
当你试图建立时,你不会得到更好的消息列表。&#34;这些是运行时消息 - 您的文件已成功构建并运行(退出代码0
成功)。只是程序立即终止。
您可以在程序中添加类似这样的内容以等待输入:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world!";
cin.get(); // this will wait for a single character press
return 0;
}
您应该遵循一个好的教程(或参加课程)以熟悉Visual Studio - 您需要能够区分Intellisense&#34;错误&#34;,编译器错误,链接器错误和运行时输出消息,以进行任何认真的编程工作。