【问题标题】:Why can a "hello world" c++ program raise so many "iosfwd" errors in visual studio 2015?为什么“hello world”c++ 程序会在 Visual Studio 2015 中引发如此多的“iosfwd”错误?
【发布时间】:2017-03-11 02:23:32
【问题描述】:

我刚刚在 Visual Studio 2015 中输入了这个“hello world”c++ 程序:

#include<iostream>

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

然后,vs 告诉我:

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

这些错误的来源相同:

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

好吧,请忽略我的文件路径。但是iosfwd似乎是问题的核心?而iosfwd 中的一种情况是: Error C2065 'EOF': undeclared identifier

我找了很久。但是没有用。请帮助或尝试提供一些想法如何实现这一目标。提前致谢。


如果我创建一个新的Win32 Console Application" 而不是Empty Project,并使用#include "stdafx.h"(如果我不包含“stdafx.h”,它也会出错)。然后我的程序运行成功。那么,Visual Studio 的秘诀是什么。

【问题讨论】:

  • 您最初是在驱动器 F:\ 上安装 VS 还是将它移到那里?当我移动我的安装时曾经遇到过类似的问题。
  • 我想我没有移动它。
  • 我用Empty Project 试过你的代码,它运行良好。你可以坚持使用Win32 Console Application,但如果你真的想使用Empty Project,我想第一步可能是尝试重新安装Visual Studio?
  • 也许 Visual Studio 项目被配置为使用预编译的头文件?我认为使用预编译头文件时需要#include "stdafx.h"。 VS 默认使用预编译的头文件,除非你在创建新项目时告诉它不要这样做。

标签: c++ visual-studio-2015 iosfwd


【解决方案1】:

对我来说同样的问题。尝试在&lt;iostream&gt; 之前包含&lt;memory&gt;。问题消失了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-02
    • 1970-01-01
    • 2011-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多