Fix reconstructed header dropping macros whose name/value contains the include guard (#1266) - #1272
Merged
Merged
Conversation
…e include guard extract_macro_defs used a plain substring test (macro.include?(include_guard)) to filter out a header's own include guard from its reconstructed macro list. That also rejected any ordinary macro whose name or value merely happened to contain the guard string -- e.g. guard RTC_H matching inside RTC_HOUR_SECONDS' own name, or inside RTC_DAY_SECONDS' value, which references RTC_HOUR_SECONDS. Both were silently dropped from the reconstructed header, producing undeclared-identifier compile errors (GH #1266). The match is now anchored to "#define <guard>" followed by whitespace or end-of-line, matching only the guard's own definition. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
[skip ci] Co-Authored-By: Claude Sonnet 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.
Fixes #1266. This is a port of #1271 (green on
next_version) tomaster, for inclusion in 1.1.8.Root cause
extract_macro_defsfiltered a header's own include guard out of the reconstructed macro list with a plain substring test (macro.include?(include_guard)). That also rejected any ordinary macro whose name or value merely happened to contain the guard string as a substring — e.g. with guardRTC_H:Both were silently dropped from the reconstructed header, producing undeclared-identifier compile errors — exactly as reported.
Fix
The match is now anchored to
#define <guard>followed by whitespace or end-of-line, so only the guard's own definition line matches.Tests
Same coverage as #1271: new
#extract_macro_defscases inpreprocessinator_reconstructor_spec.rbusing the reporter's own RTC example, verified failing against pre-fix code, passing after. Unit tests only, no system tests.bundle exec rake specs:unitsclean (1991 examples, 0 failures, 1 pre-existing unrelated pending).🤖 Generated with Claude Code