On Fri, Nov 18, 2011 at 8:27 AM, Jeff King <peff@xxxxxxxx> wrote: > 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. I need to save __FILE__ and __LINE__ of call site, inline functions probably don't help. >> 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). For the record, Sun C compiler 5.9 seems to support it. -- Duy -- 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