Re: [PATCH 8/8] Enable GIT_DEBUG_MEMCHECK on git_pathname()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Nov 18, 2011 at 08:12:27AM +0700, Nguyen Thai Ngoc Duy wrote:

> > Older compilers will probably barf on the variable-argument macros.
> 
> Anyway to detect if __VA_ARGS__ is supported at compile time? I guess
> #ifdef __GNUC__ is the last resort.

You can check "#if __STDC_VERSION__ >= 19901L", but that will of course
only tell you whether you have C99; older gcc (and possibly other
compilers) supported __VA_ARGS__ even before it was standardized.

But more annoying is that there isn't a great fallback to __VA_ARGS__.
If you can't use it, then every callsite has to have the same number of
arguments. So it's not like you can localize the fallback code to just
the definition.

Unless you really need macro-like behavior, you're probably better off
using a variadic function and making it a static inline on platforms
which can do so.

> notes-merge.c introduces __VA_ARGS__ since v1.7.4 so we may want to do
> something there too.

I hadn't noticed. That definitely violates our usual rules about
portability.  That usage can easily be turned into an inline function.
However, since nobody has complained in the past year, it makes me
wonder if we are overly conservative (my guess is that people on crazy
old compilers just don't keep up with git. Which maybe means they aren't
worth worrying about. But who knows).

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]