Home > Blockchain >  Are the integer types included in the stdint.h library "extended integer types"?
Are the integer types included in the stdint.h library "extended integer types"?

Time:12-08

im learning about integer conversion rank but i have a question, i often use the stdint.h library, and for what im reading about "integer conversion rank" it says:

"The rank of any standard integer type shall be greater than the rank of any extended integer type with the same size."

For what i know "int", for example, is an standard integer type, but using stdint.h i have the "int32_t" which is equal to "int"

I know that the stdint.h library uses "typedef" so theorically int and int32_t are equal, but i have read in forums that "extended integer types" uses the (u)intxx_t to be referred

So my question is, the "exact width integers" included in the stdint.h library are "standard integer types" or they are considered "extended integer types"?

Thanks for your answers!

CodePudding user response:

Types listed in stdint.h are not necessarily extended integer types.

Section 6.2.5 of the C standard defines extended integer types:

4 There are five standard signed integer types, designated as signed char, short int, int, long int, and long long int. (These and other types may be designated in several additional ways, as described in 6.7.2.) There may also be implementation-defined extended signed integer types. The standard and extended signed integer types are collectively called signed integer types.

...

7 The standard signed integer types and standard unsigned integer types are collectively called the standard integer types, the extended signed integer types and extended unsigned integer types are collectively called the extended integer types.

So the above states that extended integer types are implementation defined.

Section 7.20p4 describes the types defined in the stdint.h header:

For each type described herein that the implementation provides, 261) <stdint.h> shall declare that typedef name and define the associated macros. Conversely, for each type described herein that the implementation does not provide, <stdint.h> shall not declare that typedef name nor shall it define the associated macros. An implementation shall provide those types described as ‘‘required’’, but need not provide any of the others (described as ‘‘optional’’).

So this states that the types in stdint.h are typedefs for other types. The critical part is footnote 261 which states:

  1. Some of these types may denote implementation-defined extended integer types.

So whether or not the types in stdint.h are considered standard or extended integer types depends on what they are a typedef of.

  • Related