-1

It is my understanding that std::pair and std::tuple are basically compile-time constructs that don't require any particular runtime support, and can be implemented (if messily) purely using template constructs.

So why is it that when I #include <tuple> in my bare metal project from arm-none-eabi's C++ standard library, it includes <array> which includes <stdexcept> which finally includes <string>, making it impossible for me to include it as this then reaches into headers like wchar.h and bits/postypes.h that aren't included in arm-none-eabi-gcc? What am I doing wrong?

I can use std::pair just fine from <utility> but std::tuple just won't work without me editing the C++ standard library headers to remove the offending include, which is clearly unacceptable.

Is this an oversight or limitation that effectively prevents bare metal programs from using perfectly legitimate parts of the STL, or am I supposed to be doing something more here? Do I need to provide my own wchar.h and other headers??

I would really appreciate an explanation of what the authors of those headers are expecting here.

Thomas
  • 3,321
  • 1
  • 21
  • 44
  • There are plenty of third party STL variants, some being aimed at the precise use case you're facing (google for "embedded stl" or something like this). The STL variant bundled with GCC is the same for all builds and is primarily targeted at "normal", multiprocess-OS based apps. – oakad Oct 27 '17 at 04:38

1 Answers1

1

Assuming you want to compile for Cortex-M, use ARM's own GCC distribution, formerly called GCC-ARM-Embedded. Tuple works fine there.

Btw, Tuple never was part of the STL. You probably meant to say C++ Standard Library.

Erlkoenig
  • 2,664
  • 1
  • 9
  • 18
  • Okay, that clears it up, I looked a bit further after you pointed me to the same distribution I was using and noticed that in my version, all the standard C headers like wchar.h were missing. Then I found that Archlinux packages newlib separately (as `arm-none-eabi-gcc` and `arm-none-eabi-newlib` respectively). It works now. Thanks!! – Thomas Oct 27 '17 at 08:12