This is the mail archive of the
mailing list for the glibc project.
Re: Add macros for diagnostic control, use for scanf %a tests
- From: Paul Eggert <eggert at cs dot ucla dot edu>
- To: Joseph Myers <joseph at codesourcery dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Tue, 25 Nov 2014 18:02:04 -0800
- Subject: Re: Add macros for diagnostic control, use for scanf %a tests
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot DEB dot 2 dot 10 dot 1411252243090 dot 17237 at digraph dot polyomino dot org dot uk> <54752077 dot 7000002 at cs dot ucla dot edu> <alpine dot DEB dot 2 dot 10 dot 1411260040470 dot 17237 at digraph dot polyomino dot org dot uk>
Joseph Myers wrote:
it doesn't work to have the pragmas in the same macro as the code
Then how about using an inline function instead of a macro? Something like this:
static inline __attribute__ ((__always_inline__)) int
C99_sscanf (char const *str, char const *format, ...)
return sscanf (str, format, __builtin_va_arg_pack ());
This should silence the warning more accurately than the pragma does.
Similarly, if we're worried about fread_unlocked complaining about a zero-sized
argument, perhaps we can write an inline wrapper for it; that should silence thw
warning more accurately.
One might reasonably object that I'm going off the deep end here: after all,
it's just a test case and we needn't care all that much about narrowly tailoring
warning-suppression for test cases. I'm sympathetic to that objection. But in
that case, why not just disable the warning for the entire test-case compilation
unit? That'd be simpler yet. There'd be no need for pragma macros or for
pushing or popping diagnostics, and it'd be simpler for others to follow what's
I'm sorry if I appear to be niggling here, it's just that we've had a lot of
experience dodging these warnings in GNU applications ...