3

C++11 has fixed width, 2's complement types: (u)int8_t, (u)int16_t, etc.

However, these types are optional.

Sometimes I need to use these types, so my code might be less portable because of this.

Is there any platform (with C+11 compiler available) currently, where these types don't exist?

Is there any "general-purpose" (I know it's a vague word, but I'd like to have an answer, where DSP's and other very domain-specific platforms are excluded, as these platforms are rarely a target for porting software) platform currently, where these types don't exist?

Note 1: I know, that there is hardware which doesn't support these types. However, all such hardware I know doesn't have a C++11 conformant compiler. This question is about a C++11 implementation, where fixed width types are actually missing.

Note 2: I know, that there are mandatory least and fast types, but this question is about exact width types.

geza
  • 28,403
  • 6
  • 61
  • 135
  • [C++11 on exotic hardware](https://stackoverflow.com/q/45119928/995714) – phuclv Jul 30 '18 at 09:51
  • @phuclv: yes, that's a question from me too. Its a more general question. I put this question, because I didn't get specific answers to that question, stating C++ conformance. I tend to think that actually there is no general purpose platform, which doesn't have fixed width types, so it is absolutely fine to use them. – geza Jul 30 '18 at 09:53

1 Answers1

3

intXX_t are only possible on two's complement platforms where CHAR_BIT is a power of 2. But even on those platforms not all intXX_t may exist. For example DSPs where CHAR_BIT == 16 obviously can't have int8_t. There will be no int16_t on DSPs where CHAR_BIT == 24 or CHAR_BIT == 32.

One example is the TI C2000 series. It has C99 support, so it does have stdint.h. Unfortunately it doesn't have C++11 support yet but many other TI DSPs like C6000 do have C++14 support

Another example is the SHARC DSPs where CHAR_BIT == 32 and have both C99 and C++11 support

Those types will also not exist one one's complement and sign-magnitude platforms.

phuclv
  • 37,963
  • 15
  • 156
  • 475
  • Note, currently one's complement and sign-magnitude platforms are very rare. Even, there is a proposal to declare that a signed number is 2's complement: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0907r0.html – geza Jul 30 '18 at 09:32
  • 1
    @geza The fact that they do or do not is completely unrelated to the fact that these platforms exist and do not have these types defined. If you think about it, no compiler is fully C++11 compliant; there will always be bugs. – rubenvb Jul 30 '18 at 09:35
  • 1
    There are certainly standalone C++11 implementations that target particular DSPs. Bugs and compiler-specific extensions aside, those implementations do tend to claim conformance. – Peter Jul 30 '18 at 09:41
  • Thanks for the research! Note, I've extended my question a little bit. Sorry about that. I'm interested in platforms, which are general purpose, and usually people port software to. For DSP's, we don't port software usually, but specifically create SW for them. – geza Jul 30 '18 at 09:52
  • @rubenvb: but I don't care about platforms where there is no C++11 compiler. That's why I specifically highlighted that I'm interested in platforms, where a C++11 compiler do exist. How could `int16_t` be missing, if there is no C++11 compiler in the first place? – geza Jul 30 '18 at 09:57