Standardize .h recursive #include guard names #24048
Open
+11
−11
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.
Some header files in the Perl core have guards to keep a recursive #include from compiling them again. This is standard practice in C coding, and I was surprised at how many headers don't have it. These seem to rely on only being included from perl.h, which does have its own guard.
Most of the guards use a common naming convention. If the file is named foo.h, the guard is named 'PERL_FOO_H'. Often, though, a trailing underscore is added, 'PERL_FOO_H_', making the convention slightly fuzzy. The 'PERL_' is not added if the file 'foo' already includes 'perl' in its name,
Those rules are enough to describe all the guards in the core, except for the outliers in this commit, plus perl.h.
There are occasions in various Perl scripts that examine our source that we want to create a pattern that matches the header guard name for a particular file. In spite of the slight fuzziness, that's easy using the above rules, except for the ones in this commit, and perl.h. It would be better for that code to not have to worry about the outliers, and since these are arbitrary names, we can just change them to follow the rules that already apply to most.
This commit changes the names of the outliers so that the only file the rules don't apply to is perl.h. Its guard is named H_PERL. That spelling is used in Encode, so it's not so easy to change it seamlessly. I'm willing to live with it continuing to be an outlier for the code I write.