*This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Open status.*

**Section:** 16.4 [cstdint] **Status:** Open
**Submitter:** Thomas Köppe **Opened:** 2016-11-12 **Last modified:** 2018-04-04

**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 16.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]*

**Previous resolution [SUPERSEDED]:**

This wording is relative to N4687.

Change 16.4.1 [cstdint.syn], header

<cstdint>synopsis, as indicated:[…] using int64_t =signed integer type;// optionalusing intN_t =see below;// optional, see below[…] using int_fast64_t =signed integer type; using int_fastN_t =see below;// optional, see below[…] using int_least64_t =signed integer type; using int_leastN_t =see below;// optional, see below[…] using uint64_t =unsigned integer type;// optionalusing uintN_t =see below;// optional, see below[…] using uint_fast64_t =unsigned integer type; using uint_fastN_t =see below;// optional, see below[…] using uint_least64_t =unsigned integer type; using uint_leastN_t =see below;// optional, see belowusing uintmax_t =unsigned integer type; using uintptr_t =unsigned integer type;// optional#define INT_N_MINsee below; #define INT_N_MAXsee below; #define UINT_N_MAXsee below; #define INT_FASTN_MINsee below; #define INT_FASTN_MAXsee below; #define UINT_FASTN_MAXsee below; #define INT_LEASTN_MINsee below; #define INT_LEASTN_MAXsee below; #define UINT_LEASTN_MAXsee below; #define INTMAX_MINsee below; #define INTMAX_MAXsee below; #define UINTMAX_MAXsee below; #define INTPTR_MINsee below; #define INTPTR_MAXsee below; #define UINTPTR_MAXsee below; #define PTRDIFF_MINsee below; #define PTRDIFF_MAXsee below; #define SIZE_MAXsee below; #define SIGATOMIC_MINsee below; #define SIGATOMIC_MAXsee below; #define WCHAR_MINsee below; #define WCHAR_MAXsee below; #define WINT_MINsee below; #define WINT_MAXsee below; #define INTN_C(value)see below; #define UINTN_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 whenNis not 8, 16, 32 or 64. The exact-width typesNintandN_tuintforN_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. [NNote:The macrosINTandN_CUINTcorrespond to the typedef namesN_Cint_leastandN_tuint_least, respectively. —N_tend note]Change 27.12.2 [cinttypes.syn] as indicated:

#define PRId~~N~~Nsee below#define PRIi~~N~~Nsee below#define PRIo~~N~~Nsee below#define PRIu~~N~~Nsee below#define PRIx~~N~~Nsee below#define PRIX~~N~~Nsee below#define SCNd~~N~~Nsee below#define SCNi~~N~~Nsee below#define SCNo~~N~~Nsee below#define SCNu~~N~~Nsee below#define SCNx~~N~~Nsee below#define PRIdLEAST~~N~~Nsee below#define PRIiLEAST~~N~~Nsee below#define PRIoLEAST~~N~~Nsee below#define PRIuLEAST~~N~~Nsee below#define PRIxLEAST~~N~~Nsee below#define PRIXLEAST~~N~~Nsee below#define SCNdLEAST~~N~~Nsee below#define SCNiLEAST~~N~~Nsee below#define SCNoLEAST~~N~~Nsee below#define SCNuLEAST~~N~~Nsee below#define SCNxLEAST~~N~~Nsee below#define PRIdFAST~~N~~Nsee below#define PRIiFAST~~N~~Nsee below#define PRIoFAST~~N~~Nsee below#define PRIuFAST~~N~~Nsee below#define PRIxFAST~~N~~Nsee below#define PRIXFAST~~N~~Nsee below#define SCNdFAST~~N~~Nsee below#define SCNiFAST~~N~~Nsee below#define SCNoFAST~~N~~Nsee below#define SCNuFAST~~N~~Nsee below#define SCNxFAST~~N~~Nsee 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 16.4.1 [cstdint.syn], and moreover, theNfscanfmacros are provided unless the implementation does not have a suitablefscanflength modifier for the type.

*[2018-04-03; Geoffrey Romer suggests improved wording]*

**Proposed resolution:**

This wording is relative to N4727.

Change 16.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 27.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>`[…]-?-

`PRI`macros that use the placeholderare defined if and only if the implementation actually provides the corresponding typedef name in 16.4.1 [cstdint.syn].*N*`SCN`macros that use the placeholderare defined if and only if the implementation actually provides the corresponding typedef name and the implementation has a suitable*N*`fscanf`length modifier for the type.