Skip to content

Silence spurious MODE_BUTTON_PIN warning in PlatformIO builds#37

Merged
laurb9 merged 1 commit into
masterfrom
pio-redefine-warning
Jul 12, 2026
Merged

Silence spurious MODE_BUTTON_PIN warning in PlatformIO builds#37
laurb9 merged 1 commit into
masterfrom
pio-redefine-warning

Conversation

@laurb9

@laurb9 laurb9 commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Spotted while verifying #36: every PlatformIO build logs warning: "MODE_BUTTON_PIN" redefined during the "Converting tiny_scope.ino" step.

Diagnosis

PIO's .ino→.cpp converter runs a gcc -fdirectives-only pass that registers all #defines while passing #if conditionals through unevaluated — so the two per-board #define MODE_BUTTON_PIN lines look like a redefinition to the converter only. The converted file keeps the conditionals intact and the real compile picks the right pin on every board (verified by capturing the generated .ino.cpp mid-build), so this was purely cosmetic — but it shows up in every build log and already confused one reviewer.

Fix

Selecting the pin via an enum instead of #define — same compile-time constant, nothing for the converter's macro table to warn about. An #ifndef guard was tested first and does not help (the pass ignores conditionals entirely).

Verification

  • No redefined warning in any of the 5 pio envs
  • arduino-cli --warnings all: uno and feather_m0 clean; uno flash/RAM byte-identical (21756 B / 490 B)
  • make sim-test passes

Agent: claude-opus-4-8 implement / claude-fable-5 validate (claude-code)

🤖 Generated with Claude Code

PlatformIO's .ino conversion pass (gcc -fdirectives-only) registers every
#define while passing #if conditionals through unevaluated, so the per-board
MODE_BUTTON_PIN definitions looked like a redefinition in every pio build
log. The compiled code was always correct; the warning was converter noise.
Use an enum instead - same constant, nothing for the converter to warn on.

Verified: no redefined warning in any pio env; uno/feather_m0 arduino-cli
builds clean with --warnings all, uno flash/RAM byte-identical; sim-test
passes.

Agent: claude-opus-4-8 implement / claude-fable-5 validate (claude-code)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@laurb9
laurb9 merged commit cf12131 into master Jul 12, 2026
10 checks passed
@laurb9
laurb9 deleted the pio-redefine-warning branch July 12, 2026 02:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant