qt - 在 qt creator(mingw 4.8 和 qt 5.3)中使用 c++11 功能时出现奇怪的错误

标签 qt c++11 mingw qt-creator mingw32

我想在 qt creator 的项目中使用 c++11。我试图通过将以下内容之一添加到 .pro 文件来添加 c++11 支持:

 CONFIG += c++11

或者
 QMAKE_CXXFLAGS += -std=c++11

但是它们都不适合我,在将这些添加到 .pro 文件后,编译器(mingw 4.8)给了我很多错误,例如:

C:/Qt/Qt5.3.2/Tools/mingw482_32/i686-w64-mingw32/include/c++/cstdint:48:11: error: '::int8_t' has not been declared using ::int8_t; ^

C:/Qt/Qt5.3.2/Tools/mingw482_32/i686-w64-mingw32/include/c++/cstdint:49:11: error: '::int16_t' has not been declared using ::int16_t; ^

C:/Qt/Qt5.3.2/Tools/mingw482_32/i686-w64-mingw32/include/c++/cstdint:50:11: error: '::int32_t' has not been declared using ::int32_t; ^

C:/Qt/Qt5.3.2/Tools/mingw482_32/i686-w64-mingw32/include/c++/cstdint:51:11: error: '::int64_t' has not been declared using ::int64_t; ^

C:/Qt/Qt5.3.2/Tools/mingw482_32/i686-w64-mingw32/include/c++/cstdint:53:11: error: '::int_fast8_t' has not been declared using ::int_fast8_t;



问题是什么??!

最佳答案

如果您使用的是 cstdint ,您必须提供需要using对于这些类型。

插入

using ::int8_t;
using ::int16_t;
using ::int32_t;
using ::int64_t;
using ::int_fast8_t;

(以及报告丢失的所有其他内容)到发生这些错误的源文件中。

关于此主题的更多信息 here .

关于qt - 在 qt creator(mingw 4.8 和 qt 5.3)中使用 c++11 功能时出现奇怪的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31228354/

相关文章:

python - Qt5/PyQt5 : Custom QML components with QML frontend and Python backend

c++ - 避免复制返回当前对象

c++ - 将闭包作为“类方法指针”?

c++ - 为 C/C++ 设置 Windows 构建环境的最佳方法

c++ - `fopen` 和 QT(MinGW) 错误

macos - Mac OS X 文件关联有效,但文件图标未更改

c++ - Qt weatherinfo demo中,部分内容超出窗口边界

debugging - 使用 rebase.exe 从 msys/mingw gcc 构建的 dll 中提取调试信息?

qt - QML FolderListModel 过滤掉文件并仅显示文件夹

c++ - 我的 g++ 使用 vector<weak_ptr> erase() 方法生成奇怪的警告