Re: [PATCH v4 01/16] git-compat-util: introduce macros to disable "-Wsign-compare" warnings
- From
karthik nayak <karthik.188@gmail.com>
- Date
- Dec 6, 2024, 12:32 UTC
- Message-ID
- <CAOLa=ZRjo27U5fWkqV8GOOO6HUF_=dgDD1Dhm=5Tb5JLT0fOCQ@mail.gmail.com>
- In-Reply-To
- <20241206-pks-sign-compare-v4-1-0344c6dfb219@pks.im>
Patrick Steinhardt <ps@pks.im> writes: [snip]
Show 11 quoted lines
> diff --git a/git-compat-util.h b/git-compat-util.h > index a06d4f3809e5664863d4d0f312c88b3e1364ee74..e283c46c6fa06e4079851296a55c9bd5472a65b4 100644 > --- a/git-compat-util.h > +++ b/git-compat-util.h > @@ -44,6 +44,16 @@ struct strbuf; > #define GIT_GNUC_PREREQ(maj, min) 0 > #endif > > +#if defined(__GNUC__) || defined(__clang__) > +# define PRAGMA(pragma) _Pragma(#pragma) > +# define DISABLE_WARNING(warning) PRAGMA(GCC diagnostic ignored #warning)
Seems like clang [1] also support `#pragma GCC diagnostic`, so this works with both.
Show 7 quoted lines
> +#else > +# define DISABLE_WARNING(warning) > +#endif > + > +#ifdef DISABLE_SIGN_COMPARE_WARNINGS > +DISABLE_WARNING(-Wsign-compare) > +#endif
Looks good.
Thanks
[1]: https://clang.llvm.org/docs/UsersManual.html#controlling-diagnostics-via-pragmas