2
votes

I'm using Microsoft Visual Studio Express 2013 and have written the following code

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

I get the following errors

1 IntelliSense: PCH warning: cannot find a suitable header stop location. An IntelliSense PCH file was not generated.

2 IntelliSense: expected a declaration Error 3 error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?

I've tried adding '#include "stdafx.h" but this makes no difference. I've got precompiled header ticked and if I untick it I get the following messages when I attempt to build.

'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).
1
Why is this tagged for VB.NET?Steven Doggart
It sounds like you either messed up some of the settings or deleted the files and replaced them with your own. I suggest starting over with a new project, and start with the files they supply.crashmstr
Hi, I've completely re installed Visual Studio, didn't work.user3375439
These are not compiler errors, these are intellisense errors. The listing you show is the output when you run the program in the debugger. What's the problem, then?Marius Bancila
The latter aren't compile-time errors; their symbol-load notifications simply informing you there are no symbols available for the debugger to consume for those libraries. Your code compiled correctly in the latter example and ran. What its doing is up to you. And note your program's symbols were loaded 9the first message in your load output during run).WhozCraig

1 Answers

5
votes

The problem with stdafx.h is best solved by simply not using precompiled headers, you don't need them for test programs.

You don't get the ohter list of messages "when you attempt to build." These are runtime messages - you file has built and run successfully (exit code 0 is success). It's just that the program terminates immediately.

You can add something like this to your program to wait for some input:

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

You should follow a good tutorial (or attend a class) to familiarise yourself with Visual Studio - you'll need to be able to tell apart Intellisense "errors", compiler errors, linker errors and runtime output messages to do any serious programming work.