Size Prefixes
Size prefixes are required in ANSI-C programs that use printf
() in order to indicate the size and type of the conversion argument. The D compiler performs this processing for your printf
() calls automatically, so size prefixes are not required. Although size prefixes are provided for C compatibility, their use is explicitly discouraged in D programs because they bind your code to a particular data model when using derived types. For example, if a typedef
is redefined to different integer base types depending on the data model, it is not possible to use a single C conversion that works in both data models without explicitly knowing the two underlying types and including a cast expression, or defining multiple format strings. The D compiler solves this problem automatically by allowing you to omit size prefixes and automatically determining the argument size.
The size prefixes can be placed just prior to the format conversion name after any flags, widths, and precision specifiers. The size prefixes are as follows:
-
h
-
Specifies that a following
d
,i
,o
,u
,x
, orX
conversion applies to a short or unsigned short. -
l
-
Specifies that a following
d
,i
,o
,u
,x
, orX
conversion applies to a long or unsigned long. -
ll
-
Specifies that a following
d
,i
,o
,u
,x
, orX
conversion applies to a long long or unsigned long long. -
L
-
Specifies that a following
e
,E
,f
,g
, orG
conversion applies to a long double. -
l
-
Specifies that a following
c
conversion applies to awint_t
argument, and that a followings
conversion character applies to a pointer to awchar_t
argument.