`#include ` with `-std=c++0x` is broken

2020-06-23 05:36发布

If I specify -std=c++0x to g++, then I can't #include <iostream>. I get the following error messages (g++ 4.4.0 under mingw):

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

Any ideas why? Has this been fixed in the latest g++? (And if so, does anybody know how to incorporate the latest g++ into Qt?)

标签: c++ qt qt4 g++ c++11
2条回答
何必那么认真
2楼-- · 2020-06-23 05:38

It seems to be a bug. There is a thread with a simple patch (in the very end).

查看更多
冷血范
3楼-- · 2020-06-23 05:46
if win32{
    QMAKE_CXXFLAGS += -std=gnu++0x
}
else {
    QMAKE_CXXFLAGS += -std=c++0x
}
查看更多
登录 后发表回答