__cplusplus define not updated for C++20 or higher

The __cplusplus macro responds to the -std options up until C++17, beyond that it does not get incremented. Any tests relying upon this macro to be defined therefore assume the compiler is not capable of C++20.

> nvc++ --version

nvc++ 26.5-0 64-bit target on x86-64 Linux -tp ivybridge 
NVIDIA Compilers and Tools
Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES.  All rights reserved.
> nvc++ -dM -E -x c++ /dev/null | grep cplusplus
#define __cplusplus 201402L
> nvc++ -std=c++17 -dM -E -x c++ /dev/null | grep cplusplus
#define __cplusplus 201703L
> nvc++ -std=c++20 -dM -E -x c++ /dev/null | grep cplusplus
#define __cplusplus 201703L

Hi Andy,

For interoperability, nvc++ uses the GNU STL, so the value of the __cplusplus will depend on the language level supported by the STL it’s using.

Do you know which GNU version is installed?

I could reproduce you’re issue with GNU 10.x and earlier, but see C++20 with GNU 11.x and later:

GNU 10.2 STL:

% nvc++ --std=c++20 --gcc-toolchain=/home/sw/thirdparty/gcc/gcc-10.2.0/Linux_x86_64/ -V26.5 -dM -E -x c++ /dev/null | grep cplusplus
#define __cplusplus 201709L

GNU 11.2 STL:

% nvc++ --std=c++20 --gcc-toolchain=/home/sw/thirdparty/gcc/gcc-11.2.0/Linux_x86_64/ -V26.5 -dM -E -x c++ /dev/null | grep cplusplus
#define __cplusplus 202002L

GNU 15.2 STL:

% nvc++ --std=c++20 --gcc-toolchain=/home/sw/thirdparty/gcc/gcc-15.2.0/Linux_x86_64/ -V26.5 -dM -E -x c++ /dev/null | grep cplusplus
#define __cplusplus 202002L
% nvc++ --std=c++23 --gcc-toolchain=/home/sw/thirdparty/gcc/gcc-15.2.0/Linux_x86_64/ -V26.5 -dM -E -x c++ /dev/null | grep cplusplus
#define __cplusplus 202302L

-Mat

Thanks, I understand. I’m using OpenSUSE Leap 15.6 which, although itself is EOL, is according to the HPC SDK release notes the highest supported OpenSUSE Leap one can use. It comes with a very old GCC, so I guess I could either switch distribution or install a newer GCC toolchain on the system. Even better would be if the HPC SDK could support OpenSUSE Leap16.0, which is the only Leap currently supported and receiving security updates.

It will be available in an upcoming release.

That’s great news, thanks very much.