`#include <iostream>`与`-std = c ++ 0x`被打破</iostream>

时间:2011-01-17 13:33:38

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

如果我将-std=c++0x指定为g ++,那么我不能#include <iostream>。我收到以下错误消息(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吗?)

2 个答案:

答案 0 :(得分:7)

似乎是bug。有一个thread有一个简单的补丁(最后)。

答案 1 :(得分:3)

if win32{
    QMAKE_CXXFLAGS += -std=gnu++0x
}
else {
    QMAKE_CXXFLAGS += -std=c++0x
}