1. 程式人生 > 其它 >Ubuntu20.04下,qt交叉編譯報錯::15: warning: identifier ‘nullptr‘ is a keyword in C++11 [-Wc++0x-compat]

Ubuntu20.04下,qt交叉編譯報錯::15: warning: identifier ‘nullptr‘ is a keyword in C++11 [-Wc++0x-compat]

技術標籤:Qt嵌入式開發linux

一、問題描述。

Ubuntu20.04下,qt在進行交叉編譯時,出現如下錯誤。高版本qtcreator預設使用c++11。

/home/ms/ln_work/product/ok335xD/program/project/qt/test/hello/mainwindow.h:15: warning: identifier 'nullptr' is a keyword in C++11 [-Wc++0x-compat]
  MainWindow(QWidget *parent = nullptr);

二、問題分析。

GCC 編譯器版本支援問題。

三、解決方案。

1、GCC 編譯器版本 < 4.7。

QMAKE_CXXFLAGS += -std=c++0x

2、GCC 編譯器版本 >= 4.7。

QMAKE_CXXFLAGS += -std=c++11

3、使用Qt5。

CONFIG += c++11