0

I'm trying to compile a C++ project under different Linux OS's. Under Fedora 27 all compiles great. Under CentOS 6 it fails with

error: ‘nullptr’ was not declared in this scope

which I read means the wrong compiler is being used. But, my qmake file contains:

CONFIG += C++14
QMAKE_CXXFLAGS += -no-pie
QMAKE_LFLAGS += -no-pie

On Fedora 27 the resultant Makefile contains:

CXXFLAGS      = -pipe -Wall -g -W -D_REENTRANT -fPIC $(DEFINES)

On CentOS 6 the resultant Makefile contains:

CXXFLAGS      = -pipe -Wall -g -std=gnu++0x -W -D_REENTRANT -fPIC $(DEFINES)

I concluded that the problem is CentOS 6 doesn't support nullptr (c++ 14), and gnu++0x is as recent as is available.

Is it possible to work around this problem? Is there a compatibility include (for 'nullptr', 'override' keywords)?

I don't want to maintain seperate code bases for CentOS6 vs CentOS7.

TSG
  • 4,242
  • 9
  • 61
  • 121
  • [`nullptr`](https://en.cppreference.com/w/cpp/language/nullptr) should be valid as of `c++11`. What compiler version are you using on CentOS? – G.M. May 30 '19 at 21:27
  • Compiler in CentOS 6 is "gcc 4.4.7 20120313". I think the keywords nullptr and override are the only features I've taken advantage of in C++ 14. – TSG May 31 '19 at 00:09
  • According to [this](https://en.cppreference.com/w/cpp/compiler_support#cpp11) `nullptr` requires at least `gcc 4,6` and `override` requires `4.7`. – G.M. May 31 '19 at 07:27
  • I found that too. I'm wondering if there is a compatibility include file that will define the C++ 14 keywords to something compatible with C++11 – TSG May 31 '19 at 11:32

0 Answers0