countunique
countunique

Reputation: 4296

Is intmax_t the same as long long int?

By POSIX, intmax_t designates a signed integer type capable of representing any value of any signed integer type.

Would it be correct that in C99/C11 that intmax_t is always the same size as long long int?

Upvotes: 20

Views: 18049

Answers (2)

C99 N1256 standard draft

6.2.5 Types tells us about "extended signed 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. 29)

29) Therefore, any statement in this Standard about signed integer types also applies to the extended signed integer types.

7.18.1.5 Greatest-width integer types says that intmax_t is the largest possible "signed integer type", thus including extended ones:

1 The following type designates a signed integer type capable of representing any value of any signed integer type:

intmax_t

6.4.4.1 Integer constants then makes it pretty clear that the extended integer types might be larger than any of the standard ones:

6 If an integer constant cannot be represented by any type in its list, it may have an extended integer type, if the extended integer type can represent its value.

Upvotes: 9

R.. GitHub STOP HELPING ICE
R.. GitHub STOP HELPING ICE

Reputation: 215387

No. intmax_t can be an extended integer type larger than long long. I'm not aware of any systems that have it defined as such, but you should not assume in application code that they're the same. (Assuming they're the same in OS code may be acceptable if your OS always guarantees that, but it's still probably a bad idea.)

Upvotes: 16

Related Questions