代码不会编译

 挚远-十年 发布于 2023-01-20 12:31

我正在使用Microsoft Visual Studio Express 2013并编写了以下代码

#include 
using namespace std;
int main()
{
    cout << "Hello world!";
    return 0;
}

我收到以下错误

1智能感知:PCH警告:找不到合适的标头停止位置.未生成IntelliSense PCH文件.

2 IntelliSense:预期声明错误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).

Reinstate Mo.. 5

这个问题stdafx.h通过简单地不使用预编译头最好解决的,你不需要他们的测试程序.

当你试图构建时,你没有得到消息列表.这些是运行时消息 - 您的文件已成功构建并运行(退出代码0成功).只是程序立即终止.

你可以在你的程序中添加这样的东西来等待一些输入:

#include 
using namespace std;
int main()
{
  cout << "Hello world!";
  cin.get();  // this will wait for a single character press
  return 0;
}

您应该遵循一个好的教程(或参加课程)以熟悉Visual Studio - 您需要能够区分Intellisense"错误",编译器错误,链接器错误和运行时输出消息来进行任何认真的编程工作.

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有