3.6.1.14 Smart-io-format Option
The -msmart-io-format="fmt"
option,
where fmt
is a string containing formatted,
printf-style conversion specifications, notifies the compiler that the listed
specifications are used by smart IO functions and that the IO library code linked in
must be able to process them. See 4.10.1 Smart IO Routines for more information on this feature.
To reduce code size, the compiler customizes library code associated with the print and
scan families of smart IO functions, based on the conversion specifications present in
the format strings collated across all calls to these functions. This feature is controlled by
the -msmart-io
option.
In some situations, the compiler is unable to determine usage information from the
formatted IO function call. In such cases, the
-msmart-io-format="fmt"
option can be used to
indicate the required conversion specifications for the linked IO functions, for
example, -msmart-io-format=fmt="%d%i%s."
Without this option, the
compiler makes no assumptions about IO usage and ensures that fully functional IO
functions are linked into the final program image.
vscanf("%d:%li", va_list1);
vprintf("%-s%d", va_list2);
vprintf(fmt1, va_list3); // ambiguous usage
vscanf(fmt2, va_list4); // ambiguous usage
When processing the last two
calls, the compiler cannot deduce any usage information from either the format strings,
nor the arguments. In these instances, the -msmart-io-format
option can
be used and will potentially allow more optimal formatted IO functions to be generated,
thus reducing the program's code size. For example, if the format strings pointed to by
fmt1
and fmt2
collectively use only the
"%d"
, "%i"
and "%s"
conversion
specifiers, the -msmart-io-format=fmt="%d%i%s"
option should be
issued.The fmt
string may contain any valid printf-style
conversion specification, including flags and modifiers (for example
"%-13.9ls"
), and should reflect exactly those conversion
specifications used by the functions whose usage is ambiguous. Failure to include a
specification in the fmt
argument where it has been
used by the formatted IO functions might result in code failure.
If fmt
is an empty string or contains no discernible
conversion specifications, an error will be issued. Characters other than those in valid
conversion specifications are permitted, but will be ignored.
This option may be used multiple times on the command line. The conversion specifications used with each option are accumulated.