“#include <iostream>”与“-std=c++0x”一起使用会出现问题。

4
如果我在g++中指定-std=c++0x,那么我就无法#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中吗?)


如果您移除了“-std=c++0x”,编译器会告诉您什么? - Simone
1
这看起来像是MinGW的C++库/头文件中的一个错误,而不是G++中的。 - Fred Foo
@Simone:没有使用-std=c++0x,我就没有问题。 - TonyK
请查看是否适用:https://dev59.com/gXA75IYBdhLWcg3wJFmY - Simone
2个回答

7

这似乎是一个错误。有一个帖子有一份简单的修补程序(在最后)。


谢谢!那个有效。 (您可能需要在您的答案中将“路径”编辑为“补丁”) - TonyK

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接