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

[PATCH] remote.c: spell __attribute__ correctly

From
Jeff King <peff@peff.net>
Date
Apr 25, 2016, 21:15 UTC
Message-ID
<20160425211523.GA11227@sigill.intra.peff.net>
In-Reply-To
<20160425211030.GA10309@sigill.intra.peff.net>
On Mon, Apr 25, 2016 at 05:10:30PM -0400, Jeff King wrote:
Show 13 quoted lines
> It should be handled in git-compat-util.h, which is included by cache.h,
> which is included by remote.c.
> 
> There we have:
> 
>   #ifndef __GNUC__
>   #ifndef __attribute__
>   #define __attribute__(x)
>   #endif
>   #endif
> 
> which should make it a noop on compilers which don't know about it. Is
> VS (or another file) setting __GNUC__?
Of course it helps if we spell the name right...
-- >8 --
Subject: remote.c: spell __attribute__ correctly

We want to tell the compiler that error_buf() uses printf()-style arguments via the __attribute__ mechanism, but the original commit (3a429d0), forgot the trailing "__". This happens to work with real GNUC-compatible compilers like gcc and clang, but confuses our fallback macro in git-compat-util.h, which only matches the official name (and thus the build fails on compilers like Visual Studio).

Reported-by: Philip Oakley <philipoakley@iee.org>
Signed-off-by: Jeff King <peff@peff.net>
---
 remote.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/remote.c b/remote.c
index 28fd676..ddc4f8f 100644
--- a/remote.c
+++ b/remote.c
@@ -1660,7 +1660,7 @@ int branch_merge_matches(struct branch *branch,
 	return refname_match(branch->merge[i]->src, refname);
 }
 
-__attribute((format (printf,2,3)))
+__attribute__((format (printf,2,3)))
 static const char *error_buf(struct strbuf *err, const char *fmt, ...)
 {
 	if (err) {
-- 
2.8.1.562.gc7e1b3c
Previous: Jeff KingNext: Philip Oakley
Message 3 of 8 in “definition for _attribute() in remote.c”
  1. Philip OakleyApr 25, 2016
  2. Jeff KingApr 25, 2016
  3. remote.c: spell __attribute__ correctlyJeff King, Apr 25, 2016
  4. Philip OakleyApr 25, 2016
  5. Ramsay JonesApr 25, 2016
  6. Philip OakleyApr 26, 2016
  7. Philip OakleyApr 25, 2016
  8. Jeff KingApr 25, 2016

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.