Modern C++: C++ Patterns to Make Embedded Programming More Productive - Steve Bush - CppCon 2022

  Рет қаралды 37,550

CppCon

CppCon

Күн бұрын

Пікірлер: 35
@matthieulabas
@matthieulabas Жыл бұрын
5:28 Declarative GPIO 16:15 Compiler-driven lookup table generation 23:21 Address-like structures 31:00 Lean stream-based I/O 40:55 Using heap in embedded applications (arena allocators) 50:23 Unlock std::chrono 54:56 Unlock std::random
@yyyy-uv3po
@yyyy-uv3po Жыл бұрын
Really liked the readable numeric structures. Thank you for your time.
@maxtruxa
@maxtruxa Жыл бұрын
`std::format` and by extension `std::print`/`std::println` are actually extensible just as well as iostreams (take a look at `std::formatter`), even allowing for custom format options which was not possible with iostreams.
@yezariaelll
@yezariaelll Жыл бұрын
Nice talk and great tips, thanks!
@brunizzl
@brunizzl Жыл бұрын
The custom shift operator overloads shown at 39:13 can actually also be done for std::iostream. These are normal operator overloads and thus are discovered by the overload resolution if they are declared in the same namespace as the (second) argument or as the caller.
@gustavojmalano
@gustavojmalano Жыл бұрын
That is clear, but he got rid of std::iostreams because they are too expensive (talking about binary size) for an embedded device.
@RadimPolasek
@RadimPolasek Жыл бұрын
thank you for such great hints
@hstrauss2214
@hstrauss2214 Жыл бұрын
I think that the overload/redefinition of std::chrono::highresolution_clock::now() presented at 52:40 is not allowed by the standard and maybe not even possible.
@patricklittle1002
@patricklittle1002 3 ай бұрын
How does the LUT table work when the coefficients are pulled from the factory calibration data stored in micro?
@eotcoldhymns2930
@eotcoldhymns2930 Жыл бұрын
why have not used enum class? why not put & in to const std::array coeff?
@hstrauss2214
@hstrauss2214 Жыл бұрын
The code presented at about 28:30 centainly does not work at all. There are useless lines like "index == 1;" and a wrong mix up of 'index' and 'count' for 'result.mData' and 'text'. Finally, to parse a hex string to bytes, two characters need to be combined to a single byte. Can not see this happinging anywhere in the code.
@szymoniak75
@szymoniak75 11 ай бұрын
19:53 are these actually are going to be evaluated at compile time? since std::pow is not constexpr?
@stefanalecu9532
@stefanalecu9532 4 ай бұрын
It will be constexpr in C++26, it's not hard to write your own
@eriktheheroful
@eriktheheroful Жыл бұрын
Great talk!
@danielmilyutin9914
@danielmilyutin9914 Жыл бұрын
So title changed. And I thought I missed talk "Modern C++ to Impress Your Embedded Dev Friends" :-)
@verycucumber
@verycucumber Жыл бұрын
I think it is not optimal to configure pins one by one in a loop, it is basically writes few bits (via read, bitwise-OR, write) into the same MMIO register again and again. What I do is I calculate a bunch of registers values (during compilation) and write those constants into MMIO registers. If it takes 10 registers to configure GPIO, it takes 10 writes then. No loops, no bitwise-OR.
@lukasz_kostka
@lukasz_kostka Жыл бұрын
I'm curious how you did that. Can you share some code ?
@wojtekburzynski654
@wojtekburzynski654 Жыл бұрын
But do you need this to be optimal? Correct me if I'm wrong, but you configure IO pins is once in a lifetime of a program, so i doesn't matter if you save couple of writes.
@HelderParracho
@HelderParracho Жыл бұрын
@@wojtekburzynski654 it might be important to put the IO pins into a safe and known state as fast as possible, depending on your application and/or hardware.
@szymoniak75
@szymoniak75 11 ай бұрын
@@HelderParracho so as always... use proper tool for a job
@vi_volga
@vi_volga Жыл бұрын
Thank you!
@jasoncole7711
@jasoncole7711 Жыл бұрын
Very useful talk, especially for those with a C background, but yes we know what Proctor & Gamble do....... skip the first 4 minutes
@christophclear1438
@christophclear1438 Жыл бұрын
19:30 std::pow is _not_ `constexpr`...
@destiny_02
@destiny_02 Жыл бұрын
I believe it is in C++23
@peterlauro9222
@peterlauro9222 Жыл бұрын
@@destiny_02believenes has nothing to do with reality. (have a look at c++ standard section 28.7.1 Header synopsis). on g++ compiler it's accepted because the internal implementation of std::pow is based on internal __builtin_pow functions. Just take a simple code: constexpr auto i = std::pow(2.0, 3.5); on g++ is going to compile, on clang++ and msvc compilers, the compilation fails. The approach presented in the talk is not supported by the c++ standard.
@nextlifeonearth
@nextlifeonearth Жыл бұрын
@@peterlauro9222 IMO pretty much all functions in cmath should be constexpr and if they aren't, it's an oversight.
@hstrauss2214
@hstrauss2214 Жыл бұрын
@@nextlifeonearth It is not really an oversight. Overall, it is just not as easy as it seems. The math functions can have side effects, like setting the errno variable for certain input values. A constexpr function can not set errno.
@la_ki
@la_ki Жыл бұрын
First time I heard for resistor divider.
@Dziaji
@Dziaji Жыл бұрын
This talk is more like "c++ basics that might impress a first year CS student"
@peterfistin8584
@peterfistin8584 Жыл бұрын
True, but there are hundreds of companies that still use the most basic approaches from the 90'. The presenter shows here a much modern way - that's why it is important to have those sessions.
@mapron1
@mapron1 Жыл бұрын
Embedded programmers (at least all I knew) usually use C++ as C with classes/destructors. So anything beyond that will be an impression for them.
@theondono
@theondono Жыл бұрын
@@peterfistin8584 habitual reminder that this wasn’t because of backwardness, but because up until ARM became the de facto standard, most C++ compilers had no guarantees about supporting features past C89.
@drnoob13
@drnoob13 Жыл бұрын
Many embedded engineers write C++ code as C with a C++ compiler. Introducing neat modern C++ practices for embedded programming bring net benefits to every one.
@ch33rfulness
@ch33rfulness Жыл бұрын
@@mapron1 True, I’m one of them 🤣 Been involved in a dozen of companies, in safety critical applications…the core functionally was always C, and only some fancy libraries were C++, but as you’ve said, we’ve been using the C++ in a very simple way. It makes sense, if you think about it. I think that C allows us to understand easily the propagation of a signal from hardware to the topmost application layer.
ТВОИ РОДИТЕЛИ И ЧЕЛОВЕК ПАУК 😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 7 МЛН
If people acted like cats 🙀😹 LeoNata family #shorts
00:22
LeoNata Family
Рет қаралды 33 МЛН
How to Fight a Gross Man 😡
00:19
Alan Chikin Chow
Рет қаралды 20 МЛН
[SEI' 24] Modern Systems Programming: Rust and Zig - Aleksey Kladov
55:18
CeSIUM - Centro de Estudantes de Engenharia Informática da Universidade do Minho
Рет қаралды 4,2 М.
Back to Basics: C++ API Design - Jason Turner - CppCon 2022
1:00:42
C++ Lambda Idioms - Timur Doumler - CppCon 2022
1:04:45
CppCon
Рет қаралды 52 М.