2

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!

dbush
  • 205,898
  • 23
  • 218
  • 273
Cblue X
  • 143
  • 6
  • 1
    The types declared in `stdint.h` are implementation-defined. Any that are typedefs (or aliases, or macro macro expansions .....) that are equivalent to standard types (e.g. `int`, etc) are not extended types - a `typedef` creates an alternative name for a type, not a new type. If any of the types in `stdint.h` are not the standard types, then they *may be* extended types. The standard doesn't say much in such cases. – Peter Dec 07 '22 at 05:52
  • 1
    TL;DR: C allows for implementation-defined types beyond the standard ones. For example C90 might have supported `long long` as an extended integer type. So if you make a compiler you are free to create some type `long long long` that is 128 bits. I don't know of any compiler that does this however. Most 64 bit compilers have implemented the largest type `size_t` and `ptrdiff_t` as 64 bits. – Lundin Dec 07 '22 at 10:55

1 Answers1

5

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.

dbush
  • 205,898
  • 23
  • 218
  • 273