Skip to content

Documentation: Add a page on printf. - #21506

Merged
acassis merged 1 commit into
apache:masterfrom
casaroli:printf-doc-up
Nov 9, 2026
Merged

acassis merged 1 commit into
apache:masterfrom
casaroli:printf-doc-up

Conversation

@casaroli

@casaroli casaroli commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

One commit: the page only. It describes the code of #21505 and #21507, both merged. Part of #21467, step 5.

Summary

A new page, Documentation/os/libs/libc/printf.rst, linked from the libc index. It explains how printf works in NuttX:

  • Each conversion, flag, length, width and precision, with examples and their output.
  • Each option and profile, and what it prints when it is off, also LIBC_PRINTF_EXACT and LIBC_PRINTF_EXACT_LDOUBLE of libs/libc/stream: Print floating point on the bits with integers in printf(). #21507.
  • ? for a conversion that is off.
  • What happens on an unknown conversion and on a truncated format.
  • The boundary of correct and wrong usage: if the compiler accepts the call, it is correct usage.
  • Flash and stack per profile, with measured numbers.
  • What is outside the guarantee.

Impact

Documentation only. No code changes.

Testing

Each example is real: the output on the page comes from a run of the same calls on NuttX, rv-virt:nsh under QEMU, with the Full profile, and with all options off for the table of what a feature prints when it is off. The examples and the size tables come from #21507 at 374a600, the head with the %#g, * and fprintf() fixes: 5 profiles run, 32 size builds.

sphinx-build -M html . _build -W --keep-going with Sphinx 6.2.1 from the Pipfile: no warning from this page. The one warning of the run is plantuml command cannot be run in another page: this host has no plantuml. After the move to master as one commit (the page of #21506 and the update of #21507 together), sphinx-build -b html -W of the page with stream.rst: no warning.

@github-actions github-actions Bot added Area: Documentation Improvements or additions to documentation Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces. labels Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

arduino-mega2560

  • flash: .data +16 B (+0.0%, 66,603 B / 262,144 B, total: 25% used)
  • sram: .data +16 B (+0.6%, 2,803 B / 8,192 B, total: 34% used)

esp32-devkitc

  • ROM: .dram0.data +4 B, .flash.rodata +24 B, .flash.text -20 B (+0.0%, 129,360 B / 4,194,272 B, total: 3% used)
  • dram0_0_seg: .dram0.data +4 B (+0.0%, 10,028 B / 180,736 B, total: 6% used)
  • drom0_0_seg: .flash.rodata +24 B (+0.2%, 13,948 B / 4,194,272 B, total: 0% used)
  • irom0_0_seg: .flash.text -20 B (-0.0%, 95,180 B / 3,342,304 B, total: 3% used)

hifive1-revb

  • flash: .data +8 B, .text +12 B (+0.0%, 86,112 B / 4,194,304 B, total: 2% used)
  • sram: .data +8 B (+0.2%, 3,964 B / 16,384 B, total: 24% used)

mirtoo

  • kseg0_progmem: .data +4 B, .text +12 B (+0.0%, 68,440 B / 131,072 B, total: 52% used)
  • kseg1_datamem: .data +4 B (+0.2%, 2,604 B / 32,256 B, total: 8% used)

qemu-armv8a

  • Code: .rodata +16 B, .text.__dtoa_engine -4 B (+0.0%, 360,964 B)
  • Data: .data.g_version +2 B (+0.0%, 77,919 B)

rx65n-rsk2mb

  • RAM: .data +4 B (+0.1%, 6,702 B / 262,144 B, total: 3% used)
  • ROM: .rodata +12 B (+0.0%, 91,716 B / 2,097,152 B, total: 4% used)

s698pm-dkit

  • Code: .text +32 B (+0.0%, 389,904 B)

stm32-nucleo-f103rb

  • flash: .text +16 B (+0.0%, 34,908 B / 131,072 B, total: 27% used)

No memory changes detected for:


Catch memory regressions in CI with MemBrowse. Free for open source.

@casaroli
casaroli force-pushed the printf-doc-up branch 3 times, most recently from c073cc9 to 71fadff Compare November 8, 2026 13:11
@github-actions github-actions Bot added Size: L The size of the change in this PR is large and removed Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces. labels Nov 8, 2026
xiaoxiang781216
xiaoxiang781216 previously approved these changes Nov 8, 2026
@casaroli casaroli linked an issue Nov 8, 2026 that may be closed by this pull request
5 tasks done
The page explains how printf() works in NuttX: each conversion, flag,
length, width and precision with examples and their output, each option and
profile and what it prints when it is off, what happens on an unknown
conversion and on a truncated format, what is correct and wrong usage, the
flash and stack cost, and what is outside the guarantee.

It describes the code of apache#21505 and apache#21507: the options LIBC_PRINTF_HEXFLOAT,
LIBC_PRINTF_C23, LIBC_PRINTF_PERCENT_N, LIBC_PRINTF_EXACT and
LIBC_PRINTF_EXACT_LDOUBLE, and %e, %f and %g with 17 significant digits and
no floating point operation.

The output in the examples comes from a run of the same calls on NuttX, in
Default and in Full.

Part of apache#21467

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <[email protected]>
@casaroli
casaroli marked this pull request as ready for review November 9, 2026 05:06
@acassis
acassis merged commit 5f0bfc5 into apache:master Nov 9, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Documentation Improvements or additions to documentation Size: L The size of the change in this PR is large

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] printf conformance: never crash, and options for flash size

3 participants