mirror of
https://github.com/git/git.git
synced 2026-03-11 09:29:49 +01:00
git-compat-util.h: move warning infra to prepare for PCHs
The "git-compat-util.h" header is supposed to be the first header included by every code compilation unit. As such, a subsequent commit will start to precompile this header to speed up compilation of Git. This will cause an issue though with the way that we have set up the "-Wsign-compare" warnings. It is expected that any compilation unit that fails with that compiler warning sets `DISABLE_SIGN_COMPARE_WARNINGS` before including "git-compat-util.h". If so, we'll disable the warning right away via a compiler pragma. But with precompiled headers we do not know ahead of time whether the code unit wants to disable those warnings, and thus we'll have to precompile the header without defining `DISABLE_SIGN_COMPARE_WARNINGS`. But as the pragma statement is wrapped by our include guards, the second include of that file will not have the desired effect of disabling the warnings anymore. We could fix this issue by declaring a new macro that compilation units are expected to invoke after having included the file. In retrospect, that would have been the better way to handle this as it allows for more flexibility: we could for example toggle the warning for specific code blocks, only. But changing this now would require a bunch of changes, and the churn feels excessive for what we gain. Instead, prepare for the precompiled headers by moving the code outside of the include guards. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
f6897d7e72
commit
34288b2b47
@@ -34,10 +34,6 @@ struct strbuf;
|
||||
# define DISABLE_WARNING(warning)
|
||||
#endif
|
||||
|
||||
#ifdef DISABLE_SIGN_COMPARE_WARNINGS
|
||||
DISABLE_WARNING(-Wsign-compare)
|
||||
#endif
|
||||
|
||||
#undef FLEX_ARRAY
|
||||
#define FLEX_ARRAY /* empty - weather balloon to require C99 FAM */
|
||||
|
||||
@@ -1099,3 +1095,7 @@ extern int not_supposed_to_survive;
|
||||
#endif /* CHECK_ASSERTION_SIDE_EFFECTS */
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef DISABLE_SIGN_COMPARE_WARNINGS
|
||||
DISABLE_WARNING(-Wsign-compare)
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user