2025-05-27 3:12 AM
What instructions do you follow to implement a C++ class and use it in "main.c"?
Suppose it's a simple project, like blinking the LED.
2025-05-28 4:12 AM
> But others have no negative impact on memory usage or runtime behaviour and might be very useful on small systems as well.
No doubt - as long as there is sufficient performance and resources.
Maybe you were never involved in high-volume / low-cost projects, with managers insisting on lowest BOM costs.
Another point, although applicable to a certain niche, are toolchains and test tools.
My company's software projects involves SIL-2 certification, requiring more or less complete test coverage. And our test tool supported only plain C for a very long time.
Secondly, we use pre-certified libraries and RTOSes for most of our ECUs, which implies the toolchain used for exactly that certification. And none of those use C++.
2025-05-28 6:31 AM
I use C++ pretty exclusively for programming micros, and I keep main.c named main.c, and everything works fine.
Choose how to go downstream but don't fight the current. There are no showstoppers using C++ in the current CubeMX framework. main.h can be included if you need access to variables, and it has the __cplusplus guards.
2025-05-28 7:22 AM - edited 2025-05-28 7:26 AM
C++ was lacking some useful features of C (for one, designated initializers) but newest C++ standard is going to make C++ a complete superset of C. When this happens, c++ will go mainstream in embedded. But even then... ants, cockroaches, sharks, crocodiles still exist and may outlast fancy creations. Long live C23.
By the way, the new AI-assisted Mojo language compiles native code for heterogeneous systems (like, CPU + GPU) and this is going to become a killer. Not Rust, sorry Microsoft.