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

Re: [PATCH] Add the GIT_SENTINEL macro

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 19, 2013, 07:18 UTC
Message-ID
<7vmwpjyq4a.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20130719033634.GB27853@google.com>
Jonathan Nieder <jrnieder@gmail.com> writes:
Show 18 quoted lines
> Junio C Hamano wrote:
>
>> It seems to apply well on the tip of jk/gcc-function-attributes.
>>
>>  - This macro is not about "git" at all, so I'll edit the patch to
>>    call it GCC_ATTR_SENTINEL before applying.
>
> Would naming it something like LAST_ARG_MUST_BE_NULL instead make
> sense?  That way, if some other compiler gains a different syntax for
> the same annotation, it would be possible to do
>
> 	#if defined(__GNUC__) && __GNUC__ >= 4
> 	# define LAST_ARG_MUST_BE_NULL __attribute__((sentinel))
> 	#elif defined(_MSC_VER) && _MSC_VER > 27
> 	# define LAST_ARG_MUST_BE_NULL __declspec(lastargnull)
> 	#else
> 	# define LAST_ARG_MUST_BE_NULL
> 	#endif

I do like last-arg-must-be-null name for its descriptiveness; with the example of NORETURN vs NORETURN_PTR, however, I am not quite convinced that it would help reusing the same macro to different compilers.

I would say it is already sheer luck that GCC's __attribute__(()) and MSC's __declspec() both come at the same place in the function declaration syntax, i.e. before the usual declaration. Your next compiler may want the magic immediately before the closing semicolon of the declaration, for example.

Previous: Jonathan NiederNext: Ramsay Jones
Message 6 of 7 in “Add the GIT_SENTINEL macro”
  1. Add the GIT_SENTINEL macroRamsay Jones, Jul 18, 2013
  2. Jeff KingJul 18, 2013
  3. Jonathan NiederJul 18, 2013
  4. Junio C HamanoJul 19, 2013
  5. Jonathan NiederJul 19, 2013
  6. Junio C HamanoJul 19, 2013
  7. Ramsay JonesJul 20, 2013

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.