Re: [PATCH 8/8] Enable GIT_DEBUG_MEMCHECK on git_pathname()
- From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
- Date
- Nov 18, 2011, 01:50 UTC
- Message-ID
- <CACsJy8CB6VXjyC-M4C9qGm-n73Kuf1Q0SbH4Ync5Osts-uufQQ@mail.gmail.com>
- In-Reply-To
- <20111118012715.GA7826@sigill.intra.peff.net>
On Fri, Nov 18, 2011 at 8:27 AM, Jeff King <peff@peff.net> wrote:
Show 19 quoted lines
> 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.
Show 9 quoted lines
>> 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