Declaring fixed-size integer typedef in Standard C

前端 未结 5 1314
谎友^
谎友^ 2021-01-13 08:28

Is there a reliable way to declare typedefs for integer types of fixed 8,16,32, and 64 bit length in ISO Standard C?

When I say ISO Standard C, I mean that strictly:

5条回答
  •  青春惊慌失措
    2021-01-13 08:59

    No, you can't do that.

    Now, if you want to count a multi-stage configuration process like Gnu configure as a solution, you can do that and stick to C89. And there are certainly various types you can use that are in C89, and that will DTRT on almost every implementation that's around today, so you get the sizes you want and stick with pure conforming C89. But the bit widths, while what you want, will not in general be specified by the standard.

提交回复
热议问题