Search notes:

C++ preprocessor macro __cplusplus

The __cplusplus preprocessor macro is defined if the compilation unit is compiled with a C++ compiler. Its value corresponds to the C++ standard that the compiler uses to compile a compilation unit.
In PowerShell, its value can quickly be printed like so:
write-output '' | g++ -dM -E -x c++  - | select-string  __cplusplus      # or
ech          '' | g++ -dM -E -x c++  - | findstr        __cplusplus      # or
In other shells with
g++ -dM -E -x c++  /dev/null | grep -F __cplusplus

main.cpp

#include <iostream>
#include <iomanip>

int main(int argc, char* argv[]) {

//  Compile with g++ -std=c++11 or g++ -std=c++14 to
//  have different output.
//  See also https://stackoverflow.com/a/7132549/180275
    std::cout << std::setw(6) << argv[0] << ": " <<  __cplusplus << std::endl;
}
Github repository about-cpp, path: /preprocessor/macros/predefined/__cplusplus/main.cpp

Makefile

all: cpp98 gcc98 cpp1z cpp11 gnu11 cpp14 gnu14 cpp17
	@ ./cpp98
	@ ./gcc98
	@ ./cpp11
	@ ./gnu11
	@ ./cpp14
	@ ./gnu14
	@ ./cpp1z
	@ ./cpp17

cpp98: main.cpp
	@g++ -std=c++98 main.cpp -o cpp98

gcc98: main.cpp
	@g++ -std=gnu++98 main.cpp -o gcc98

cpp11: main.cpp
	@g++ -std=c++11 main.cpp -o cpp11

gnu11: main.cpp
	@g++ -std=gnu++11 main.cpp -o gnu11

cpp14: main.cpp
	@g++ -std=c++14 main.cpp -o cpp14

gnu14: main.cpp
	@g++ -std=gnu++14 main.cpp -o gnu14

cpp1z: main.cpp
	@g++ -std=c++1z main.cpp -o cpp1z

cpp17: main.cpp
	@g++ -std=c++17 main.cpp -o cpp17

clean:
	@rm -f cpp98 gcc98 cpp11 gnu11 cpp14 gnu14 cpp1z cpp17

FORCE: ;
Github repository about-cpp, path: /preprocessor/macros/predefined/__cplusplus/Makefile

Output

./cpp98: 199711
./gcc98: 199711
./cpp11: 201103
./gnu11: 201103
./cpp14: 201402
./gnu14: 201402
./cpp1z: 201500
./cpp17: 201500

Shell / g++

A similar result can be printed from a Linux shell:
#!/bin/sh

for cppstd in c++98 gnu++98 c++03 gnu++03 c++11 gnu++11 c++14 gnu++14 c++17 gnu++17 c++20 gnu++20 c++2a gnu++2a
do
   printf "cppstd = %-7s : %s\n" $cppstd  $( echo '__cplusplus' | gcc -E -x c++ -std=$cppstd - | grep -v '^#' ) 
done
Github repository about-preprocessor, path: /macros/predefined/__cplusplus-g++
This script prints:
cppstd = c++98   : 199711L
cppstd = gnu++98 : 199711L
cppstd = c++03   : 199711L
cppstd = gnu++03 : 199711L
cppstd = c++11   : 201103L
cppstd = gnu++11 : 201103L
cppstd = c++14   : 201402L
cppstd = gnu++14 : 201402L
cppstd = c++17   : 201703L
cppstd = gnu++17 : 201703L
cppstd = c++20   : 201709L
cppstd = gnu++20 : 201709L
cppstd = c++2a   : 201709L
cppstd = gnu++2a : 201709L

See also

Preprocessor: macros
When invoking g++, the standard can be chosen with the compiler option -std.

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1738216210, '3.138.123.215', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/C-C-plus-plus/preprocessor/macros/predefined/__cplusplus(147): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78