Dear Experts,
I am going to use C++17 to compile my program ... Traditionally, C language is used to program microcontrollers. On the other hand, I need to use C++ for my project . When we read comments of experts on the Internet, some of them suggest NOT to use Template at all, when using C++ for microcontrollers, but I need to take advantage of : "Template meta programming in C++ .
Also, when we consider limitation of ESP-IDF for C++,on their website, they mentioned :
**Various section attributes (such as IRAM_ATTR) are ignored when used with template functions.**
(Please see this link: https://stackoverflow.com/questions/743 ... n-template)
Here are my questions:
1-Can I use C++17 ,in my project without any problem when I use Templates?
2-What is my best option to program new esp32-s3 boards with C++17(DevKit-C1 for example, Flash: 16/8MB - RAM: 8MB ) :
a)ESP-IDF and VSCode
b)Arduino IDE for windows
c)Platformio extension for VScode
Which one: a, b or c?
3-Is there any suggestion or comment to consider when we use C++17 for this new esp32-s3 boards?
Your consideration is highly appreciated.
Regards,
Quantum.
Using C++17 for new esp32-s3(Flash:16/8MB,RAM:8MB)
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: Using C++17 for new esp32-s3(Flash:16/8MB,RAM:8MB)
Seemingly, unless you use attributes. I'm not sure how relevant that issue still is, but not being able to handle attributes will mostly affect the placement of functions in IRAM, and you can get around that by simply not having templates for anything that happens in interrupt handlers or callbacks that run in an interrupt context.
Whichever one you like. All are based on ESP-IDF, which provides the C++ support.
2-What is my best option to program new esp32-s3 boards with C++17(DevKit-C1 for example, Flash: 16/8MB - RAM: 8MB ) :
a)ESP-IDF and VSCode
b)Arduino IDE for windows
c)Platformio extension for VScode
Which one: a, b or c?
IDF v5.1 already uses C++23, so C++17 is supported by default.3-Is there any suggestion or comment to consider when we use C++17 for this new esp32-s3 boards?
-
- Posts: 1734
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: Using C++17 for new esp32-s3(Flash:16/8MB,RAM:8MB)
Likely the same crowd who tell you that you can use C89 - if you're not serious enough to program in assembly.When we read comments of experts on the Internet, some of them suggest NOT to use Template at all, when using C++ for microcontrollers,
I found that templates are extremely valuable, especially for MCU programming. With MCUs' constraints of RAM and CPU power, and with one binary only ever running in one specific hardware environment, it's very beneficial to push as much work as possible to the compiler instead of doing it at runtime. ("compile-time polymorphism",...)
I'm not sure what the actual current state of gcc, gcc's attributes, C++ attributes, and template functions is, but I don't find it hard to just avoid having to use (section) attributes on template functions.
3-Is there any suggestion or comment to consider when we use C++17 ... ?
1) Talking about C++ things that don't work: Calling virtual member functions in an IRAM-only context (IRAM-ISR) does not work.
2) Don't use C++17. Go straight for C++20 (or later) - concepts are really helpful when templating.
Re: Using C++17 for new esp32-s3(Flash:16/8MB,RAM:8MB)
Dear @ESP_Sprite & @Microcontroller,
Thank you for your time and attention to reply to my questions. I really appreciate that .
Regarding my second question:
I assume : Arduino can not support full features of C++,specially when using Templates . Arduino facilitates working with microcontrollers in some ways, but it has downsides, probably . Do you agree?
Regards,
quantum.
Thank you for your time and attention to reply to my questions. I really appreciate that .
Regarding my second question:
I assume : Arduino can not support full features of C++,specially when using Templates . Arduino facilitates working with microcontrollers in some ways, but it has downsides, probably . Do you agree?
Regards,
quantum.
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: Using C++17 for new esp32-s3(Flash:16/8MB,RAM:8MB)
That's very hard to say. Obviously Arduino, like every SDK, has its downsides. I don't think Arduino has any additional restrictions on templates than any SDK has.
Who is online
Users browsing this forum: Bing [Bot] and 118 guests