【问题标题】:Error when running CLion C++ Sample Program运行 CLion C++ 示例程序时出错
【发布时间】:2016-07-25 02:32:59
【问题描述】:

我刚刚下载了 CLion 和 minGW,并创建了一个项目。经过一番折腾后,我设法获得了运行示例 Hello World 程序的按钮。但是,当我尝试运行该程序时,它说它编译到 50%,然后才给我这个错误日志:https://justpaste.it/wm14

它非常长,大约 450 行。而且我不知道为什么会出现此错误...任何帮助将不胜感激! :)

错误的前几行如下。在以In file included from 开头的错误列表中存在与此类似的重复模式,后跟错误列表,例如has not been declared usingis not a member of 'std'does not name a type

In file included from c:\mingw\include\wchar.h:208:0,
from c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\cwchar:44,
from c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\bits\postypes.h:40,
from c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\iosfwd:40,
from c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\ios:38,
from c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\iostream:39,
from C:\Users\Ole\Documents\programming\c++\testing\main.cpp:1:
c:\mingw\include\sys/stat.h:173:14: error: '_dev_t' does not name a type
struct _stat __struct_stat_defined( _off_t, time_t );
^
c:\mingw\include\sys/stat.h:173:14: error: '_ino_t' does not name a type
struct _stat __struct_stat_defined( _off_t, time_t );
^
c:\mingw\include\sys/stat.h:173:14: error: '_mode_t' does not name a type
struct _stat __struct_stat_defined( _off_t, time_t );
^

代码如下:

#include "iostream"

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

我已设法将问题隔离到包含语句。如果我删除包含(和 cout),它构建得很好,但如果我添加包含(而不是 cout),它会给我同样的错误。

更新

我设法通过简单地删除 minGW 并安装 cygwin 来解决这个问题。

【问题讨论】:

标签: c++ clion


【解决方案1】:

尝试使用

#include <iostream>

而不是

#include "iostream"
  • 就像 Richard C 建议的那样,我也猜想这是一个搜索路径问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-07-23
    • 1970-01-01
    • 1970-01-01
    • 2021-09-26
    • 2014-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多