Which version of c++ is currently supported

Just want to ask which version of c++ is currently supported in the newest arduino ide?? Is it 17 or 11.

It depends on which processor platform you're asking about.

1 Like

you can infer the C++ standard version being used by looking at the compiler output in the Arduino IDE console. The compiler flags and options used during compilation, including the C++ standard version, are typically displayed in the verbose output

(or go check the platform.txt for your board you'll see probably in the file somewhere -std=gnu++11 ➜ using C++ 11)

thanks so it seems as i also have c++11.
that means that i cannot compile features above c++11 or can i increase the compiler feature set and it is only reduced to c++11 for the arduino ide?

if not so i cannot compile code with e.g. the new array size determining methods like:

std::size(values);

Arduino artificially limits the C++ version to C++11. The compilers used by most Cores support newer versions, and you can enable them by modifying the platform.txt files.

Are there any downsides to doing this?

The libraries haven't been tested against the newer version of the compiler. The development and maintenance of toolchains and ensuring backward compatibility are significant considerations in deciding whether to update the supported C++ standard... Not a small decision from a $$ point of view.

Again, it depends on the platform (which you still haven't specified). The latest Teensy BSP is at C++17 and ESP32 is at C++23.

Of course, you can't use any STL templates on AVR regardless of C++ version as it's not supported on that platform.

the platform i am using is the older arduino platform. i am mainly using an arduino nano.

The ArduinoCore-AVR uses GCC 7.3.0, which supports most of C++17: Compiler support for C++17 - cppreference.com

Then, as I mentioned, you won't be able to use any STL templates (eg std::size) regardless of which version of C++ you're using.

It depends on the board you're using. You can check it with Serial.printing __cplusplus

1 Like

Good point!

The __cplusplus macro is used to indicate the version of the C++ standard that the compiler supports

➜ It expands to a long integer value that represents the year and month of the standard.

  • 199711 ➜ C++98 or C++03 standards.
  • 201103 ➜ C++11 standard.
  • 201402 ➜ C++14 standard.
  • 201703 ➜ C++17 standard.
  • 202002 ➜ C++20 standard.
  • 202302 ➜ C++23 standard.

runnning a simple sketch does show 201103 on wokwi

It gives you the version that is selected using the -std=c++xx compiler flag, or the "default" version for that compiler. This is usually significantly older than the latest version the compiler actually supports.

The C++ version that the compiler supports can be found on C++ compiler support - cppreference.com.

You right indeed. It's the version that was used to compile.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.