Live data from Hacker News

Learn Effective C++ for Embedded Code

luckyresistor.me

1–10 of 21 posts

Re: Learn Effective C++ for Embedded Code

#4

I'm a big fan of quantum leaps (www.state-machine.com) for c++ embedded. I am not affiliated with them in any way, just had a great experience with it.

I have not used their libraries or tools, but Miro Samek's book is great. There's a C implementation covered in it also. It's a bit of a master class in embedded C programming with careful use of structs and function pointers for "object orientation".

Re: Learn Effective C++ for Embedded Code

#6
I’m always under the impression that C++ has some issues when it comes to embedded and that only a subset can be used, that the stdlib and stl cannot be used. I still don’t really understand how c++ behaves with exception handling thrown in the mix, where all sort of weird gotchas seemingly come into play.

I get templates, classes, and constexpr might be incredibly valuable though. If used within reason to avoid code size issues.

Has anyone spent serious time writing large firmwares in c++ with teams? What’s debugging like? How do people agree on what subset of the language and it’s plethora of features to use?

Re: Learn Effective C++ for Embedded Code

#7
post #6

I’m always under the impression that C++ has some issues when it comes to embedded and that only a subset can be used, that the stdlib and stl cannot be used. I still don’t really understand how c++ behaves with exception handling thrown in the mix, where all sort of weird gotchas seemingly come into play. I get templates, classes, and constexpr might be incredibly valuable though. If used within reason to avoid code…

> I still don’t really understand how c++ behaves with exception handling thrown in the mix

In my experience you normally disable exceptions when working on embedded code. No RTTI either.

> What’s debugging like?

What's with debugging? Not different to C at all.

> How do people agree on what subset of the language and it’s plethora of features to use?

You agree on the language standard to use, you don't pull dependencies arbitrarily and you keep an eye on the code size and memory usage. Some things might go into project style guide which is a nice thing to have anyway.

Re: Learn Effective C++ for Embedded Code

#8
post #6

I’m always under the impression that C++ has some issues when it comes to embedded and that only a subset can be used, that the stdlib and stl cannot be used. I still don’t really understand how c++ behaves with exception handling thrown in the mix, where all sort of weird gotchas seemingly come into play. I get templates, classes, and constexpr might be incredibly valuable though. If used within reason to avoid code…

it really depends on which embedded you are talking about - 8-bit micros with 128 bytes of RAM and 250mhz 32-bit behemoths are fundamentally not programmed in the same way, and let's not talk about some ARMv8 linux-based embedded which is likely more powerful than the computer you used to play Quake III Arena on.

I'm having some fun with RP2040s and ESP32s these days and I can just use standard C++20 as understood by GCC 12 without specific restrictions except exceptions (and I'm having a lot of fun with it) - hell, there's even some boost:: usage in there.

Re: Learn Effective C++ for Embedded Code

#10
post #6

I’m always under the impression that C++ has some issues when it comes to embedded and that only a subset can be used, that the stdlib and stl cannot be used. I still don’t really understand how c++ behaves with exception handling thrown in the mix, where all sort of weird gotchas seemingly come into play. I get templates, classes, and constexpr might be incredibly valuable though. If used within reason to avoid code…

MbedOS (https://github.com/ARMmbed/mbed-os), the RTOS from ARM, has a very large C++ API (leveraging C/C++ SDKs from hardware vendors).
Post reply on HN