2

I just typed this "hello world" c++ program in visual studio 2015 :

#include<iostream>

int main() 
{
    using namespace std;
    cout << "Hello World!" << endl;
    return 0;
}

and then, vs told me :

Error   C2061   syntax error: identifier 'fpos_t'   
Error   C3646   'seekpos': unknown override 
Error   C2059   syntax error: '('       
Error   C2334   unexpected token(s) preceding '{'; skipping apparent function body      
Error   C3646   '_Fpos': unknown override specifier
Error   C4430   missing type specifier - int assumed. Note: C++ does not support default-int
Error   C2065   'EOF': undeclared identifier

these errors had the same source:

f:\microsoft visual studio 14.0\vc\include\iosfwd

well, please ignore my file path. But iosfwd seems to be the core of problems? And one of the situations in iosfwd is: Error C2065 'EOF': undeclared identifier

I am searching for a long time. But no use. Please help or try to give some ideas how to achieve this. Thanks in advance.


If i create a new Win32 Console Application" instead of Empty Project, and use #include "stdafx.h"(if I don't include"stdafx.h", it also goes wrong). Then my program runs successfully. So, what's the secret of visual studio.

t.niese
  • 39,256
  • 9
  • 74
  • 101
Passby
  • 21
  • 2
  • Have you originally installed VS on drive F:\ or did you move it there ? Had once a similar problem when I moved my installation. – Hannes Hauptmann Mar 11 '17 at 02:29
  • I think I didn't move it. – Passby Mar 11 '17 at 03:14
  • I tried your code with `Empty Project` and it worked fine. You could just stick with `Win32 Console Application`, but if you really want to use an `Empty Project`, I guess the first step is maybe to try re-installing Visual Studio? – smead Mar 11 '17 at 04:20
  • 3
    Maybe the Visual Studio project is configured to use a precompiled header file? I think `#include "stdafx.h"` is needed when a precompiled header file is used. VS uses a precompiled header by default, unless you tell it not to do so when creating a new project. – Bernard Mar 11 '17 at 04:25

1 Answers1

0

Same issue for me. Tried to include <memory> before <iostream>. The issue disappeared.

t.niese
  • 39,256
  • 9
  • 74
  • 101
Ying Dai
  • 171
  • 1
  • 6