Oracle® Solaris 11.2 Dynamic Tracing Guide

Exit Print View

Updated: July 2014
 
 

Size Prefixes

Size prefixes are required in ANSI-C programs that use printf(3C) 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 and after any flags, widths, and precision specifiers. The size prefixes are as follows:

  • An optional h specifies that a following d, i, o, u, x, or X conversion applies to a short or unsigned short.

  • An optional l specifies that a following d, i, o, u, x, or X conversion applies to a long or unsigned long.

  • An optional ll specifies that a following d, i, o, u, x, or X conversion applies to a long long or unsigned long long.

  • An optional L specifies that a following e, E, f, g, or G conversion applies to a long double.

  • An optional l specifies that a following c conversion applies to a wint_t argument, and that a following s conversion character applies to a pointer to a wchar_t argument.