Fix eaassert.h include guard#3
Open
IncludeGuardian wants to merge 1 commit intoelectronicarts:masterfrom
Open
Conversation
`eassert.h` does not have a strict enough include guard to trigger the multiple inclusion optimization on most compilers. The `#if defined(EA_PRAGMA_ONCE_SUPPORTED)` check occurs before any include of `eacompilertraits.h` (where `EA_PRAGMA_ONCE_SUPPORTED` is defined) so the preprocessor sees the `#pragma once` only if `eassert.h` is included **after** another header that includes `eacompilertraits.h`. The traditional include guard is also not strict enough to trigger the multiple-inclusion optimization as the only tokens that can appear outside of the `#ifdef`/`#endif` pair are whitespace, comments, and the null directive `#` (for certain compilers https://gcc.gnu.org/onlinedocs/cppinternals/Guard-Macros.html). However, the previously mentioned `EA_PRAGMA_ONCE_SUPPORTED` check disables this optimization. This commit moves the `#pragma once` code after the include directive where `EA_PRAGMA_ONCE_SUPPORTED` would be defined. It also tidies up the traditional include guard so that it satisfies the stricter rules mentioned above. This was issues was found with IncludeGuardian 0.0.7.
Author
|
The full output from IncludeGuardian (https://includeguardian.io) with this particular issue highlighted can be found here https://gist.github.com/IncludeGuardian/a3716704237848e258471471b058879a#file-eastl-yaml-L160-L161 |
Author
|
@grojo-ea Would anyone be able to take a look at this? |
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.
eaassert.hdoes not have a strict enough include guard to trigger the multiple inclusion optimization on most compilers.The
#if defined(EA_PRAGMA_ONCE_SUPPORTED)check occurs before any include ofeacompilertraits.h(whereEA_PRAGMA_ONCE_SUPPORTEDis defined) so the preprocessor sees the#pragma onceonly ifeaassert.his included after another header that includeseacompilertraits.h.The traditional include guard is also not strict enough to trigger the multiple-inclusion optimization as the only tokens that can appear outside of the
#ifdef/#endifpair are whitespace, comments, and the null directive#(for certain compilershttps://gcc.gnu.org/onlinedocs/cppinternals/Guard-Macros.html). However, the previously mentioned
EA_PRAGMA_ONCE_SUPPORTEDcheck disables this optimization.This commit moves the
#pragma oncecode after the include directive whereEA_PRAGMA_ONCE_SUPPORTEDwould be defined. It also tidies up the traditional include guard so that it satisfies the stricter rules mentioned above.This was issues was found with IncludeGuardian 0.0.7.