Silence spurious MODE_BUTTON_PIN warning in PlatformIO builds#37
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Spotted while verifying #36: every PlatformIO build logs
warning: "MODE_BUTTON_PIN" redefinedduring the "Converting tiny_scope.ino" step.Diagnosis
PIO's .ino→.cpp converter runs a
gcc -fdirectives-onlypass that registers all#defines while passing#ifconditionals through unevaluated — so the two per-board#define MODE_BUTTON_PINlines 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
enuminstead of#define— same compile-time constant, nothing for the converter's macro table to warn about. An#ifndefguard was tested first and does not help (the pass ignores conditionals entirely).Verification
redefinedwarning in any of the 5 pio envs--warnings all: uno and feather_m0 clean; uno flash/RAM byte-identical (21756 B / 490 B)make sim-testpassesAgent: claude-opus-4-8 implement / claude-fable-5 validate (claude-code)
🤖 Generated with Claude Code