2

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).
barak manos
  • 29,648
  • 10
  • 62
  • 114
  • 2
    Why is this tagged for VB.NET? – Steven Doggart Mar 03 '14 at 15:32
  • 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 Mar 03 '14 at 15:34
  • Hi, I've completely re installed Visual Studio, didn't work. – user3375439 Mar 03 '14 at 15:35
  • 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 Mar 03 '14 at 15:35
  • Also, that does not look like a "build" output, but results from the "Output" window from *running* the program. – crashmstr Mar 03 '14 at 15:36
  • Your pdb files cant be found, try browsing to them in the file system of your project and see if they exist – DNKROZ Mar 03 '14 at 15:36
  • @DNKROZ I strongly doubt PDBs are available for system libraries. – Angew is no longer proud of SO Mar 03 '14 at 15:39
  • 2
    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 Mar 03 '14 at 15:41
  • see this question : http://stackoverflow.com/questions/4813975/why-is-visual-studio-2010-not-able-to-find-open-pdb-files – DNKROZ Mar 03 '14 at 15:44
  • From the output. There is no problem at all. I mean the program ran and executed. The real problem is a new user will not expect that the console window closes after the program executes. – drescherjm Mar 03 '14 at 17:23

1 Answers1

5

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.

Angew is no longer proud of SO
  • 167,307
  • 17
  • 350
  • 455