Size prefixes are required in ANSI C programs that use
printf()
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
enabling you to omit size prefixes and automatically determining
the argument size.
Size prefixes can be placed just prior to the format conversion name and after any flags, widths, and precision specifiers and are as follows:
An optional
h
specifies that a followingd
,i
,o
,u
,x
, orX
conversion applies to ashort
or unsignedshort
.An optional
l
specifies that a followingd
,i
,o
,u
,x
, orX
conversion applies to along
or unsignedlong
.An optional
ll
specifies that a followingd
,i
,o
,u
,x
, orX
conversion applies to along long
or unsignedlong long
.An optional
L
specifies that a followinge
,E
,f
,g
, orG
conversion applies to along
double.An optional
l
specifies that a followingc
conversion applies to awint_t
argument, and that a followings
conversion character applies to a pointer to awchar_t
argument.