【问题标题】:`#include <iostream>` with `-std=c++0x` is broken带有 `-std=c++0x` 的 `#include <iostream>` 已损坏
【发布时间】:2011-01-17 13:33:38
【问题描述】:

如果我将-std=c++0x 指定给g++,那么我不能#include &lt;iostream&gt;。我收到以下错误消息(mingw 下的 g++ 4.4.0):

In file included from c:\qt\2010.05\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/bits/postypes.h:42,
                 from c:\qt\2010.05\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/iosfwd:42,
                 from c:\qt\2010.05\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/ios:39,
                 from c:\qt\2010.05\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/ostream:40,
                 from c:\qt\2010.05\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/iostream:40,
                 from f.cpp:1:
c:\qt\2010.05\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/cwchar:159: error: '::swprintf' has not been declared
c:\qt\2010.05\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/cwchar:166: error: '::vswprintf' has not been declared

任何想法为什么?这在最新的 g++ 中是否已修复? (如果是这样,有人知道如何将最新的 g++ 合并到 Qt 中吗?)

【问题讨论】:

  • 如果您删除 '-std=c++0x',编译器会告诉您什么?
  • 这看起来像是 MinGW 的 C++ 库/头文件中的错误,而不是 G++ 中的错误。
  • @Simone:没有-std=c++0x,我没有问题。

标签: c++ qt qt4 g++ c++11


【解决方案1】:

好像是bug。有一个带有简单补丁的thread(最后)。

【讨论】:

  • 谢谢!那行得通。 (您可能想在答案中将“路径”编辑为“补丁”。)
【解决方案2】:
if win32{
    QMAKE_CXXFLAGS += -std=gnu++0x
}
else {
    QMAKE_CXXFLAGS += -std=c++0x
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-12-17
    • 1970-01-01
    • 2017-04-28
    • 1970-01-01
    • 1970-01-01
    • 2018-03-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多