What is int8_t if a machine has > 8 bits per byte?

后端 未结 2 1072
借酒劲吻你
借酒劲吻你 2021-02-19 03:51

I was reading the C++ FAQ and it says

The C++ language guarantees a byte must always have at least 8 bits

So what does that mean for

2条回答
  •  生来不讨喜
    2021-02-19 04:56

    C++ (and C as well) defines intX_t (i.e. the exact width integer types) typedefs as optional. So, it just won't be there if there is no addressable unit that's exactly 8-bit wide.

    If you want an array of bytes, you should use char, as sizeof char (and signed char and unsigned char) is well-defined to always be 1 byte.

提交回复
热议问题