This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Add macros for diagnostic control, use for scanf %a tests


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 going on.

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 ...


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]