本文介紹了如何在 Qt Creator 中啟用 C++11?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
標題很自我描述.我已經下載了 Qt Creator 2.7.0,我正在嘗試編譯一些基本的 C++11 代碼:
The title is pretty self-descriptive. I've downloaded Qt Creator 2.7.0, and I am trying to compile some basic C++11 code:
int my_array[5] = {1, 2, 3, 4, 5};
for(int &x : my_array)
{
x *= 2;
}
我收到以下錯誤:
range based for loops are not allowed in c++ 98 mode
然而,根據這篇文章 此版本的 Qt Creator 支持 C++11.那么如何啟用它?
Yet, according to this article this version of Qt Creator supports C++11. So how do I enable it?
推薦答案
根據本站 添加
CONFIG += c++11
到您的 .pro 文件(參見該網頁底部).它需要 Qt 5.
to your .pro file (see at the bottom of that web page). It requires Qt 5.
其他答案,建議
QMAKE_CXXFLAGS += -std=c++11
(或 QMAKE_CXXFLAGS += -std=c++0x
)
也適用于 Qt 4.8 和 gcc/clang.
這篇關于如何在 Qt Creator 中啟用 C++11?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!