3.6 Printf Library for Floats

The MPLAB XC8 compiler does not require nor ship the AVR-GCC library dedicated to printing float-point values. References to this library must be removed.

Description

The AVR GCC compiler ships with a floating-point-specific printf-family library (libprintf_flt.a). This library is not shipped with MPLAB XC8 and if the migrated project attempts to explicitly link in this library, it will fail to build. MPLAB XC8 on the other hand employs a smart-io feature to automatically link in floating-point specific code to the printing functions only when required.

Migration

No change is required to the C source code that uses any of the library functions in the printf family. If the migrated project's linker script or options refer to this library, however, these references must be removed. No replacement library is required.

The operation of the Smart IO feature is mostly automatic, however there might be instances where you can fine tune the feature's operation to reduce code size. Confirm the operation of MPLAB XC8's -msmart-io=level and -msmart-io-format="fmt" options in the MPLAB® XC8 C Compiler User’s Guide for AVR™ MCU to ensure that formatted IO in your project does not use more resource than necessary.