News for hackers. Stuff that matters.
Re:C++17’s Useful Features for Embedded Systems by kramerger on Monday May 29, 2023 @01:13PM (#36115850)
Why

    uint8_t b = 0b1111'1111;

I would rather have

    uint8_t b = 0b1111_1111;

This ' thing is hard to get right on some non-us keyboards. And yes, I've the same problem with Rust.
Re:C++17’s Useful Features for Embedded Systems by dxuh on Monday May 29, 2023 @01:24PM (#36115968)
I think you can't do that, because the underscore may start a user defined literal suffix.
Re:C++17’s Useful Features for Embedded Systems by WalterBright on Tuesday May 30, 2023 @02:25PM (#36128546)
D doesn't have a special syntax for user-defined literals, which avoids this problem completely. One can use templates for user-defined literals, such as:

    km!1000
for 1000 kilometers. Here, km is a template that takes an integer argument:

    struct Kilometer { int v; }

    template km(int V) { Kilometer km = Kilometer(V); }
Re:C++17’s Useful Features for Embedded Systems by cmovq on Monday May 29, 2023 @02:12PM (#36116425)
It could be misinterpreted as a user literal [1], for example with 0xAAAA_BBBB it is unclear whether _BBBB is a user literal. The original proposal discusses some of the alternatives [2].

[1] https://en.cppreference.com/w/cpp/language/user_literal

[2] https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n34...

Re:C++17’s Useful Features for Embedded Systems by raxxorraxor on Tuesday May 30, 2023 @03:06AM (#36121944)
Didn't know about this language feature. Seems neat. The ASM integration is also neat. If you compare that to C...

Still, I have rarely seen C++ compilers for embedded systems. Although the latter definition more and more includes PC hardware.

Re:C++17’s Useful Features for Embedded Systems by Denvercoder9 on Tuesday May 30, 2023 @03:34AM (#36122119)
> Still, I have rarely seen C++ compilers for embedded systems.

What kind of embedded systems? Even AVR has a C++ compiler.

Re:C++17’s Useful Features for Embedded Systems by raxxorraxor on Tuesday May 30, 2023 @10:10AM (#36125075)
Yeah, that was wrong. I meant there are very few serious projects implemented in C++ for µC that are restricted memory wise.

Yes, AVR has a C++ compiler, but I could imagine it doesn't support all language features. If it does it would still be discouraged to use dynamic memory allocation, which is pretty essential to leverage many advantages of object orientated languages.

Of course embedded systems aren't restricted to that anymore and you are perfectly fine to use C++ for the average ARM system that isn't as restricted memory wise.

Re:C++17’s Useful Features for Embedded Systems by mvladic on Sunday June 04, 2023 @02:33PM (#36188174)
Still, C++ is very useful on embedded systems. This article is just about that.
Re:C++17’s Useful Features for Embedded Systems by inferiorhuman on Monday May 29, 2023 @07:09PM (#36119193)
These are all valid Rust:

  0b1111_1111
  0b11111111u8
  0b1111_1111_u8
  0b11_11_11_11_u8
https://doc.rust-lang.org/book/ch03-02-data-types.html
Re:C++17’s Useful Features for Embedded Systems by connicpu on Monday May 29, 2023 @07:36PM (#36119396)
Their problem with rust is probably more all the single quotes you need for lifetimes
Re:C++17’s Useful Features for Embedded Systems by 3836293648 on Monday May 29, 2023 @07:46PM (#36119482)
Are you sure? ' easily accessible on every layout I've looked it. ´ and ` are usually a pain though. There's probably some layout where it's a pain, but it can't be that many.

But oh how I hate `. I had to edit my layout to make it typable for stupid haskell infix functions

Re:C++17’s Useful Features for Embedded Systems by WalterBright on Tuesday May 30, 2023 @02:15PM (#36128390)
> I would rather have > uint8_t b = 0b1111_1111;

In D, you would have:

    ubyte b = 0b1111_1111;