This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH v2] Use DIAG_IGNORE_NEEDS_COMMENT to silence -Wstringop-truncation
On 05/18/2018 12:21 PM, Pedro Alves wrote:
> We handle this in gdb a bit differently, and I think in a
> better way for projects other than glibc. See
> gdb/common/diagnostics.h:
>
> https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=gdb/common/diagnostics.h;hb=HEAD
>
> We have DIAGNOSTIC_PUSH/DIAGNOSTIC_POP/DIAGNOSTIC_IGNORE
> macros, too, but we don't use those directly in "client" code.
> Instead, we define warning-class-specific macros on top of
> the base DIAGNOSTIC_{PUSH,POP,IGNORE} ones, and use those
> higher level ones throughout. E.g., in this case, we'd add a new:
>
> #define DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION \
> DIAGNOSTIC_IGNORE ("-Wstringop-truncation")
The gdb solution is nice.
> in diagnostics.h, defined appropriately for the different compilers,
> and then use DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION throughout instead.
>
> I wonder whether it'd make sense to share the code between
> gdb and binutils?
I think that would make a lot of sense.
> Also, if we stick to a bfd-only solution, shouldn't the macros
> be prefixed with BFD_ ?
No need. Keep the macro names short and meanigful.
--
Cheers,
Carlos.