What should `intmax_t` be on a platform with 64-bit` long int` and `long long int`?

In the C ++ 18.4 standard, it states:

typedef 'signed integer type' intmax_t; 

By standard (s) on a platform with a 64-bit long int and 64-bit long long int , which should have this "integer type character"?

Note that long int and long long int are different fundamental types.

The C ++ standard says:

The header defines all functions, types, and macros in the same way as 7.18 in the C standard.

and 7.18 of standard C (N1548) states:

The following type denotes a signed integer type that can represent any value any signed integer type:

 intmax_t 

It would seem, in this case, that both long int and long long int have a right?

Is this the right conclusion? Will this be the standard choice?

+4
source share
2 answers

Yes, your reasoning is correct. Most real-world implementations choose the type of lowest rank that satisfies the conditions.

+4
source

Well, assuming the GNU C library is correct (from / usr / include / stdint.h):

 /* Largest integral types. */ #if __WORDSIZE == 64 typedef long int intmax_t; typedef unsigned long int uintmax_t; #else __extension__ typedef long long int intmax_t; __extension__ typedef unsigned long long int uintmax_t; #end 
+2
source

All Articles