cmake: Corrected setting of C++ language standard

* reverted old faulty mechanism to set different
  standard according to the toolchain
* Using -std=gnu++2b now for both gcc and clang
* Added a build test app to check the C++ standard in IDF
* Updated english docs to reflect the change to C++23
This commit is contained in:
Jakob Hasse
2023-04-28 15:01:15 +08:00
parent 75d00928f5
commit 0244c24c8d
6 changed files with 40 additions and 13 deletions

View File

@@ -55,7 +55,21 @@ Most ESP-IDF examples use C99 `designated initializers`_ for structure initializ
/* Correct, fields .arg and .name are zero-initialized */
};
C++ language doesn't support the designated initializers syntax until C++20. However, the GCC compiler partially supports it as an extension. When using ESP-IDF APIs in C++ code, you may consider using the following pattern::
The C++ language supports designated initializers syntax, too, but the initializers must be in the order of declaration. When using ESP-IDF APIs in C++ code, you may consider using the following pattern::
/* Correct, fields .dispatch_method, .name and .skip_unhandled_events are zero-initialized */
const esp_timer_create_args_t my_timer_args = {
.callback = &my_timer_callback,
.arg = &my_arg,
};
///* Incorrect, .arg is declared after .callback in esp_timer_create_args_t */
//const esp_timer_create_args_t my_timer_args = {
// .arg = &my_arg,
// .callback = &my_timer_callback,
//};
For more information on designated initializers, see :ref:`Designated initializers <cplusplus_designated_initializers>`. Note that C++ language versions older than C++20 (not the default in the current version of ESP-IDF) do not support designated initializers. If you have to compile code with an older C++ standard than C++20, you may use GCC extensions to produce the following pattern::
esp_timer_create_args_t my_timer_args = {};
/* All the fields are zero-initialized */