git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Jeff King <peff@peff.net>
Date
Nov 18, 2011, 01:27 UTC
Message-ID
<20111118012715.GA7826@sigill.intra.peff.net>
In-Reply-To
<CACsJy8A25SyLVKv8GwkYaHBJwU5tHqgdJK6L-upF9HWseFzCtQ@mail.gmail.com>
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
Previous: Nguyen Thai Ngoc DuyNext: Jonathan Nieder
Message 17 of 27 in “nd/resolve-ref v2”
  1. 0/8 nd/resolve-ref v2Nguyễn Thái Ngọc Duy, Nov 17, 2011
  2. 1/8 Convert many resolve_ref() calls to read_ref*() and ref_exists()Nguyễn Thái Ngọc Duy, Nov 17, 2011
  3. 2/8 Rename resolve_ref() to resolve_ref_unsafe()Nguyễn Thái Ngọc Duy, Nov 17, 2011
  4. 3/8 Re-add resolve_ref() that always returns an allocated bufferNguyễn Thái Ngọc Duy, Nov 17, 2011
  5. 4/8 cmd_merge: convert to single exit pointNguyễn Thái Ngọc Duy, Nov 17, 2011
  6. Ramkumar RamachandraNov 17, 2011
  7. Jonathan NiederNov 17, 2011
  8. 5/8 Use resolve_ref() instead of resolve_ref_unsafe()Nguyễn Thái Ngọc Duy, Nov 17, 2011
  9. 6/8 Convert resolve_ref_unsafe+xstrdup to resolve_refNguyễn Thái Ngọc Duy, Nov 17, 2011
  10. Ramkumar RamachandraNov 17, 2011
  11. Nguyen Thai Ngoc DuyNov 18, 2011
  12. 7/8 Guard memory overwriting in resolve_ref_unsafe's static bufferNguyễn Thái Ngọc Duy, Nov 17, 2011
  13. 8/8 Enable GIT_DEBUG_MEMCHECK on git_pathname()Nguyễn Thái Ngọc Duy, Nov 17, 2011
  14. Ramkumar RamachandraNov 17, 2011
  15. Jeff KingNov 17, 2011
  16. Nguyen Thai Ngoc DuyNov 18, 2011
  17. Jeff KingNov 18, 2011
  18. Jonathan NiederNov 18, 2011
  19. Nguyen Thai Ngoc DuyNov 18, 2011
  20. Jeff KingNov 18, 2011
  21. Jonathan NiederNov 18, 2011
  22. Johan HerlandNov 18, 2011
  23. Jonathan NiederNov 18, 2011
  24. Junio C HamanoNov 18, 2011
  25. Bernhard R. LinkNov 18, 2011
  26. Jonathan NiederNov 17, 2011
  27. Nguyen Thai Ngoc DuyDec 6, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.