Formatters for scanf
In a similar way to the printf function, scanf uses a common formatter, called _Scanf. The full version is quite large, and provides facilities that are not required in many embedded applications. To reduce the memory consumption, two smaller, alternative versions are also provided. Note that the wscanf versions are not affected.
This table summarizes the capabilities of the different formatters:
Formatting capabilities | Small/ SmallNoMb† | Large/ LargeNoMb† | Full/ FullNoMb† |
|---|---|---|---|
Basic specifiers | Yes | Yes | Yes |
Multibyte support | Yes/No | Yes/No | Yes/No |
Floating-point specifiers | No | No | Yes |
Floating-point specifiers | No | No | Yes |
Conversion specifier | No | No | Yes |
Scan set | No | Yes | Yes |
Assignment suppressing | No | Yes | Yes |
| No | No | Yes |
| No | No | Yes |
† NoMb means without multibytes.
The compiler can automatically detect which formatting capabilities are needed in a direct call to scanf, if the formatting string is a string literal. This information is passed to the linker, which combines the information from all modules to select a suitable formatter for the application. However, if the formatting string is a variable, or if the call is indirect through a function pointer, the compiler cannot perform the analysis, forcing the linker to select the full formatter. In this case, you might want to override the automatically selected scanf formatter.
To manually specify the scanf formatter in the IDE:Choose Project>Options>General Options to open the Options dialog box.
On the Library Options page, select the appropriate formatter.
Use one of these ILINK command line options:
‑‑redirect __Scanf=__ScanfFull ‑‑redirect __Scanf=__ScanfFullNoMb ‑‑redirect __Scanf=__ScanfLarge ‑‑redirect __Scanf=__ScanfLargeNoMb ‑‑redirect __Scanf=__ScanfSmall ‑‑redirect __Scanf=__ScanfSmallNoMb
If the compiler does not recognize multibyte support, you can enable it:
Caution
Select Project>Options>General Options>Library Options 1>Enable multibyte support.
Danger
Use the linker option ‑‑scanf_multibytes.
