Printf support in compiler

From Texas Instruments Embedded Processors Wiki

Jump to: navigation, search
Translate this page to   

Contents

Introduction

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:

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:


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.

Documentation

The option is currently documented in the MSP430 Compiler User's Guide, http://www.ti.com/lit/slau132 and C6000 Compiler Users Guide: http://www.ti.com/lit/spru187. However it is not yet included in the C28x Compiler Users Guide (spru514c) and C55x Compiler Users Guide (spru281f).

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 test.map 

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:

"${MSP430_CG_ROOT}/bin/cl430" -z
to
"${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.

Leave a Comment
Personal tools
Namespaces
Variants
Actions
Navigation
Print/export
Toolbox