cost of fprintf

后端 未结 4 359
-上瘾入骨i
-上瘾入骨i 2021-01-15 05:31

I am developing an embedded application in C++ for a platform with limited code/data RAM, but rather unlimited RAM for filesystem usage.

While looking for reducing t

4条回答
  •  北恋
    北恋 (楼主)
    2021-01-15 06:15

    It takes a reasonable amount of code to provide the full ANSI compliant printf functionality.

    Some embedded environments offer several different versions of printf that are considerably smaller, as they only offer selected functionality.

    For example, the IAR C/C++ Compiler for MSP430 (PDF), offers Tiny, Small, Large and Full implementations of the printf formatter, with the Tiny version only supporting the basic specifiers (c, d, i, o, p, s, u, X, x, and %) with no support for multibytes, floats, length modifiers, width and precision.

    If your environment offers this choice then select the version of printf (and scanf) that matches your needs and be aware of the limitations.

    If your environment does not offer this choice then take a look at the various "tiny" alternative printf implementations available (such as this one from Kustaa Nyholm of SpareTimeLabs).

提交回复
热议问题