Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

c++11

g++

qt

qt4

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?)

like image 291
TonyK Avatar asked Dec 29 '22 02:12

TonyK


2 Answers

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

like image 160
ssmir Avatar answered Dec 30 '22 14:12

ssmir


if win32{
    QMAKE_CXXFLAGS += -std=gnu++0x
}
else {
    QMAKE_CXXFLAGS += -std=c++0x
}
like image 27
dbfbf Avatar answered Dec 30 '22 14:12

dbfbf