NOTICE: The Processors Wiki will End-of-Life in December of 2020. It is recommended to download any files or other content you may need that are hosted on The site is now set to read only.

Printf support in compiler

From Texas Instruments Wiki
Jump to: navigation, search


The compiler option --printf_support=[full | minimal | nofloat] allows you to use a smaller, feature limited, variant of printf/sprintf, and make that choice at build time.

The valid values are:

  • full: Supports all format specifiers. This is the default.
  • nofloat: Excludes support for printing floating point values. Supports all format specifiers except %f, %g, %G, %e, and %E.
  • minimal: Supports the printing of integer, char, or string values without width or precision flags. Specifically, only the %%, %d, %o, %c, %s, and %x format specifiers are supported

There is no run-time error checking to detect if a format specifier is used for which support is not included.

Note: For MSP430, when creating new projects in CCS v4, this option is set to "minimal" by default to avoid large RAM requirements.

Supported versions

The following code generation tools releases support the --printf_support option:

  • C2000 - v5.0.0 and higher
  • C6000 - v6.1.0 and higher
  • C5500 - v4.1.0 and higher
  • MSP430- v3.0.0 and higher
  • ARM - v4.4.0 and higher

The best way to confirm if a release has support for this option is to extract the runtime library sources and see if the files _printfi_min.c and _printfi_nf.c exist. Also when using the option, be sure to check the link map file generated to ensure that the correct version of printfi is getting linked in.


The option is currently documented in the MSP430 Compiler User's Guide, and C6000 Compiler Users Guide: However it is not yet included in the C28x Compiler Users Guide (spru514c) and C55x Compiler Users Guide (spru281f).

An overall discussion about the Console I/O support in Compiler tools is discussed at the Tips for using printf page.

Using --printf_support option in command line

The --printf_support option is a compiler option but it needs to be passed to the linker as well. So when using it via command line, it should precede the --run_linker option, as in

cl6x --printf_support=minimal test.c --run_linker -o test.out -m 

Using --printf_support option in CCS/CCE

In CCS v4, this option should appear under Project Build Properties->C/C++ Build->Compiler->Library Function Assumptions, however, it is only visible when using newer versions of CGT. For instance, this option is not visible when using CGT v6.1.x with CCSv4 even though the option is supported with this CGT version. With CGT v7.0.x the option does appear in CCS.

For CGT versions where the option is not visible under Build Properties, the user can manually add it in the link step command as:
${command} --printf_support=minimal ${flags} ${output_flag} ${output} ${inputs}

There was also an issue in CCS v4.0.x and CCE 3.1 where this option did not work correctly because the option was not being passed correctly to the linker (SDSCM00029769). This has been fixed in CCS 4.1.0. So to use this option within CCS without manual modifications, please use v4.1.0 or higher.

To use this option in CCE 3.1 with manual modifications, do the following:

  • Go to Project Properties->C/C++ Build->MSP430 Compiler->Library Function Assumptions, and select the level of --printf_support desired. This adds the option to the compile step.
  • Go to Project Properties->C/C++ Build->MSP430 Linker, and in the Command box, change:

"${MSP430_CG_ROOT}/bin/cl430" -z
"${MSP430_CG_ROOT}/bin/cl430" --printf_support=minimal -z

This adds the option to the link step, and the option will now work correctly. After the build please check the link map file to ensure that the correct version of printf is linked in.