What's the difference between “int” and “int_fast16_t”?

前端 未结 7 1805
灰色年华
灰色年华 2020-12-05 02:18

As I understand it, the C specification says that type int is supposed to be the most efficient type on target platform that contains at least 16 bits.

I

7条回答
  •  南笙
    南笙 (楼主)
    2020-12-05 02:29

    int_fast16_t is guaranteed to be the fastest int with a size of at least 16 bits. int has no guarantee of its size except that:

     sizeof(char) = 1 and sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long).
    

    And that it can hold the range of -32767 to +32767.

    (7.20.1.3p2) "The typedef name int_fastN_t designates the fastest signed integer type with a width of at least N. The typedef name uint_fastN_t designates the fastest unsigned integer type with a width of at least N."

提交回复
热议问题