[QGIS-Developer] C++17 explicit --std required?

Greg Troxel gdt at lexort.com
Mon Dec 11 08:24:04 PST 2023


(I picked -developer rather than -user because this is in the weeds of
build issues.  Please feel free to tell me I chose wrongly if so.)

I maintain the qgis entry in pkgsrc, which is currently at 3.28.13.
(For now, we are packaging LTR.)

As part of debugging problems related to sip 6.8.0 (see
  https://github.com/qgis/QGIS/issues/55481
), I am trying to clean up the compiler situation.

pkgsrc distinguishes between

  requiring that the compiler used supports c++17

  modifying the compiler wrappers to insert --std=c++17, because
  requiring that a compiler supports c++17 is not the same as requiring
  that c++17 is default, and sometimes code sssumes it is.

My view has generally been that one cannot assume the default std of a
compiler and that if a program requires a particular level it must test
for and pass --std=c++NN (or gnu++NN if that's how it is).

I am currently building qgis with a requirement that c++17 be available
(which is satisfied because the base system compiler is gcc10) but not
set to force --std.   I see a warning:

/tmp/work/geography/qgis/work/qgis-3.28.13/src/core/settings/qgssettingsregistrycore.h:178:18: warning: inline variables are only available with '-std=c++17' or '-std=gnu++17'
  178 |     static const inline QgsSettingsEntryBool settingsEnableWMSTilePrefetching = QgsSettingsEntryBool( QStringLiteral( "enable_wms_tile_prefetch" ), QgsSettings::Prefix::WMS, false, QStringLiteral( "Whether to include WMS layers when rendering tiles adjacent to the visible map area" ) );
      |                  ^~~~~~

which suggests that the build is using C++17 features without having
inserted --std=c++17.   Reading
  https://gcc.gnu.org/projects/cxx-status.html
it looks like C++17 became default in gcc 11, and C++14 is the default
in gcc 6.1 through 10.

Looking at INSTALL.md, I don't see a requirement for C++17 stated at
all.

Looking at CMakeLists.txt, I see some kind of c++17 forcing for MSVC,
but I don't see anything for other cases.  I see some kind of forcing in
individual CMakeLists.

So:

  Is it an error of me to build without wrappers that force --std=c++17?

  Is this just a qgis bug, that files that require C++17 aren't
  cmake-coded to pass --std=c++17?

  Is this harmless and should be ignored?

  something else?



More information about the QGIS-Developer mailing list