Is the C++ Standard Library fully supported on Arduino?

后端 未结 1 481
野性不改
野性不改 2021-02-13 15:22

Not asking about but about the Standard-Library as a whole for use on micro-controllers.

I don\'t yet own an Arduino board to execute code on

相关标签:
1条回答
  • 2021-02-13 16:11

    Arduino is quite different from other embedded system projects. For one thing, it uses its own language based on C/C++. For another thing, you're dealing with incredible specialized software where it's unlikely that you'll need the heavy abstraction of <string> or <bitset>. Contrast with say a homebrew kernel, where you're dealing with desktop-grade hardware and the standard library aids development. Further, homebrew kernels eventually want to become "self-hosted", that is they can port GCC and libstdc++ to userspace. Again, this is something you're not going to see in an Arduino context.

    Now when you're talking about the libraries that come with Arduino, it's a completely different story. These are written in C or C++ and could benefit from a ported standard library, but it's unlikely to be helpful. Porting the STL is no easy task and it is very, very big. Most of the functionality is much more than necessary - do you really need a <string> or <bitset> to read or write bytes to a port? Then think about the cost and complexity from a developer point of view: the Arduino developers are going to take on this arduous (pun not intended) task to implement it, and support it when most of it is going to be unused or ripped out (think custom allocators.)

    And one final point, there are a plethora of Arduino boards out there with different specs. The standard library is an abstraction built on top of an existing C library. At one point, you're going to have to get down and dirty and actually write the code for the C library and runtime, making the standard library inherently unportable (think libstdc++-arm-none-eabi-newlib).

    Now if you're unhappy with this, you can still port a subset of the STL by following their tutorial on writing your own library for Arduino.

    0 讨论(0)
提交回复
热议问题