GNU or ISO C++ standard to use

I am test driving code::blocks. The settings provides 14 variations in C and C++ standards to use. I am working with the ESP32.

The docs via google: "C Dialect Options (Using the GNU Compiler Collection (GCC))" are undated (I hate that)

I looks like I should use -std=c++17 per "GNU dialect of -std=c++17. This is the default for C++ code."
Maybe I should be using just a C standard.

Any advice is appreciated.

I don't think I understand your question.

I usually use the latest version of C++ that my compiler supports. The latest version is C++20 which was released in December of 2020.

You can use older versions as well, but there's usually no real reason to use an older standard, and some of the features you may want to use might require a specific version. For example, if you look at the documentation for std::optional, you'll see
(since C++17), which means you'll have to use at least -std=c++17 or -std=gnu++17.

Of course, your compiler has to be modern enough to be able to use the latest standards. For example, the Arduino AVR core comes with GCC 7.3.0 which fully supports C++14 and pretty much all of C++17. You can check compiler support in this table: C++ compiler support - cppreference.com

Whether you use -std=c++xx or -std=gnu++xx depends on your preferences and whether you need portability. If you use -std=c++xx, GCC will adhere more closely to the official C++ standard. If you use -std=gnu++xx, it allows you to use GCC-specific extensions to the language, which won't work on other compilers like Clang or MSVC.
You usually don't need these extensions, so unless you have really specific needs, I'd turn them off by default.

Strider222:
The docs via google: "C Dialect Options (Using the GNU Compiler Collection (GCC))" are undated (I hate that)

That link is to the latest development version. It goes all the way up to C++23 (which is the version that's currently under development).
If you want the documentation for a specific compiler version, go to https://gcc.gnu.org/onlinedocs.

Pieter

Hello,
I tested CODE::BLOCKS as an alternative to Visual Studio. If you are using Windows, consider Visual Studio Express as a viable alternative. The debugging functions of Visual Studio are much better. (but tastes and opinions can differ)
Best Regards,
Johi.

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