**Section:** 21.4 [cstdint] **Status:** Open
**Submitter:** Thomas Köppe **Opened:** 2016-11-12 **Last modified:** 2017-10-22

**Priority: **3

**View all other** issues in [cstdint].

**View all issues with** Open status.

**Discussion:**

I would like clarification from LWG regarding the various limit macros like `INT_8_MIN` in `<cstdint>`,
in pursuit of editorial cleanup of this header's synopsis. I have two questions:

At present, macros like

`INT_8_MIN`that correspond to the optional type`int8_t`are required (unconditionally), whereas the underlying type to which they appertain is only optional. Is this deliberate? Should the macros also be optional?Is it deliberate that C++ only specifies sized aliases for the sizes 8, 16, 32 and 64, whereas the corresponding C header allows type aliases and macros for arbitrary sizes for implementations that choose to provide extended integer types? Is the C++ wording more restrictive by accident?

*[2017-01-27 Telecon]*

Priority 3

*[2017-03-04, Kona]*

C11 ties the macro names to the existence of the types. Marshall to research the second question.

Close 2764 as a duplicate of this issue.

*[2017-03-18, Thomas comments and provides wording]*

This is as close as I can get to the C wording without resolving part (a) of the issue (whether we deliberately don't
allow sized type aliases for sizes other than 8, 16, 32, 64, a departure from C). Once we resolve part (a), we need
to revisit `<cinttypes>` and fix up the synopsis (perhaps to get rid of `N`) and add similar
wording as the one below to make the formatting macros for the fixed-width types optional. For historical interest,
this issue is related to LWG 553 and LWG 841.

*[2016-07, Toronto Saturday afternoon issues processing]*

Status to Open

This wording is relative to N4640.

Append the following content to 21.4.1 [cstdint.syn] p2:

-2- The header defines all types and macros the same as the C standard library header

<stdint.h>. In particular, for each of the fixed-width types (int8_t,int16_t,int32_t,int64_t,uint8_t,uint16_t,uint32_t,uint64_t) the type alias and the corresponding limit macros are defined if and only if the implementation provides the corresponding type.

*[2017-10-21, Thomas Köppe provides improved wording]*

**Proposed resolution:**

This wording is relative to N4687.

Change 21.4.1 [cstdint.syn], header

`<cstdint>`synopsis, as indicated:[…] using int64_t =

*signed integer type*;*// optional*using int*N*_t =*see below*;*// optional, see below*[…] using int_fast64_t =*signed integer type*; using int_fast*N*_t =*see below*;*// optional, see below*[…] using int_least64_t =*signed integer type*; using int_least*N*_t =*see below*;*// optional, see below*[…] using uint64_t =*unsigned integer type*;*// optional*using uint*N*_t =*see below*;*// optional, see below*[…] using uint_fast64_t =*unsigned integer type*; using uint_fast*N*_t =*see below*;*// optional, see below*[…] using uint_least64_t =*unsigned integer type*; using uint_least*N*_t =*see below*;*// optional, see below*using uintmax_t =*unsigned integer type*; using uintptr_t =*unsigned integer type*;*// optional*#define INT_*N*_MIN*see below*; #define INT_*N*_MAX*see below*; #define UINT_*N*_MAX*see below*; #define INT_FAST*N*_MIN*see below*; #define INT_FAST*N*_MAX*see below*; #define UINT_FAST*N*_MAX*see below*; #define INT_LEAST*N*_MIN*see below*; #define INT_LEAST*N*_MAX*see below*; #define UINT_LEAST*N*_MAX*see below*; #define INTMAX_MIN*see below*; #define INTMAX_MAX*see below*; #define UINTMAX_MAX*see below*; #define INTPTR_MIN*see below*; #define INTPTR_MAX*see below*; #define UINTPTR_MAX*see below*; #define PTRDIFF_MIN*see below*; #define PTRDIFF_MAX*see below*; #define SIZE_MAX*see below*; #define SIGATOMIC_MIN*see below*; #define SIGATOMIC_MAX*see below*; #define WCHAR_MIN*see below*; #define WCHAR_MAX*see below*; #define WINT_MIN*see below*; #define WINT_MAX*see below*; #define INT*N*_C(value)*see below*; #define UINT*N*_C(value)*see below*; #define INTMAX_C(value)*see below*; #define UINTMAX_C(value)*see below*;~~-1- The header also defines numerous macros of the form:~~~~INT_[FAST LEAST]{8 16 32 64}_MIN [U]INT_[FAST LEAST]{8 16 32 64}_MAX INT{MAX PTR}_MIN [U]INT{MAX PTR}_MAX {PTRDIFF SIG_ATOMIC WCHAR WINT}{_MAX _MIN} SIZE_MAX~~~~plus function macros of the form:~~~~[U]INT{8 16 32 64 MAX}_C~~-2- The header defines all types and macros the same as the C standard library header

`<stdint.h>`. See also: ISO C 7.20-?- In particular, all types that use the placeholder

are optional when*N*is not 8, 16, 32 or 64. The exact-width types*N*`int`and*N*_t`uint`for*N*_t= 8, 16, 32, 64 are also optional; however, if an implementation provides integer types with the corresponding width, no padding bits, and (for the signed types) that have a two's complement representation, it defines the corresponding typedef names. Only those macros are defined that correspond to typedef names that the implementation actually provides. [*N**Note:*The macros`INT`and*N*_C`UINT`correspond to the typedef names*N*_C`int_least`and*N*_t`uint_least`, respectively. —*N*_t*end note*]Change 30.12.2 [cinttypes.syn] as indicated:

#define PRId

~~N~~*N**see below*#define PRIi~~N~~*N**see below*#define PRIo~~N~~*N**see below*#define PRIu~~N~~*N**see below*#define PRIx~~N~~*N**see below*#define PRIX~~N~~*N**see below*#define SCNd~~N~~*N**see below*#define SCNi~~N~~*N**see below*#define SCNo~~N~~*N**see below*#define SCNu~~N~~*N**see below*#define SCNx~~N~~*N**see below*#define PRIdLEAST~~N~~*N**see below*#define PRIiLEAST~~N~~*N**see below*#define PRIoLEAST~~N~~*N**see below*#define PRIuLEAST~~N~~*N**see below*#define PRIxLEAST~~N~~*N**see below*#define PRIXLEAST~~N~~*N**see below*#define SCNdLEAST~~N~~*N**see below*#define SCNiLEAST~~N~~*N**see below*#define SCNoLEAST~~N~~*N**see below*#define SCNuLEAST~~N~~*N**see below*#define SCNxLEAST~~N~~*N**see below*#define PRIdFAST~~N~~*N**see below*#define PRIiFAST~~N~~*N**see below*#define PRIoFAST~~N~~*N**see below*#define PRIuFAST~~N~~*N**see below*#define PRIxFAST~~N~~*N**see below*#define PRIXFAST~~N~~*N**see below*#define SCNdFAST~~N~~*N**see below*#define SCNiFAST~~N~~*N**see below*#define SCNoFAST~~N~~*N**see below*#define SCNuFAST~~N~~*N**see below*#define SCNxFAST~~N~~*N**see below*[…]-1- The contents and meaning of the header

`<cinttypes>`[…]-?- In particular, macros that use the placeholder

are defined if and only if the implementation actually provides the corresponding typedef name in 21.4.1 [cstdint.syn], and moreover, the*N*`fscanf`macros are provided unless the implementation does not have a suitable`fscanf`length modifier for the type.