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

Re: [PATCH] simple-ipc: correct ifdefs when NO_PTHREADS is defined

From
Junio C Hamano <gitster@pobox.com>
Date
May 19, 2021, 22:03 UTC
Message-ID
<xmqqh7iyxtxc.fsf@gitster.g>
In-Reply-To
<79bf42e7-3923-a901-53eb-1aac13c53e6b@jeffhostetler.com>
Jeff Hostetler <git@jeffhostetler.com> writes:
Show 21 quoted lines
>>>   #ifdef NO_UNIX_SOCKETS
>>>   #error compat/simple-ipc/ipc-unix-socket.c requires Unix sockets
>>>   #endif
>>>   +#ifdef NO_PTHREADS
>>> +#error compat/simple-ipc/ipc-unix-socket.c requires pthreads
>>> +#endif
>>> +
>> Do we want to duplicate the requirement here and risk them drifting
>> apart?
>>  ...
> Would it be better to just have something like the following at the
> top of the source files and leave the details to the Makefile:
>
>
> #ifndef SUPPORTS_SIMPLE_IPC
> /*
>  * This source file should only be included when Simple IPC
>  * is supported.  See the top-level Makefile.
>  */
> #error SUPPORTS_SIMPLE_IPC not defined
> #endif

Yeah, that is a much better message, with even less duplication, than what I sent.

I do not think #ifndef/#error/#endif adds much value, though. After all, the Makefile does not even tell us to feed this file to the compiler when the C preprocessor macro is not defined, so presumably whoever hits the #error knows s/he is doing something not supported, and the point of the new message is to help those who we failed by leaving the rest of the source file unbuildable even when we defined the C preprocessor macro in the Makefile (like the mistaken dependency on pthreads that we missed).

Thanks.
Previous: Jeff HostetlerNext: Jeff Hostetler via GitGitGadget
Message 4 of 8 in “simple-ipc: correct ifdefs when NO_PTHREADS is defined”
  1. simple-ipc: correct ifdefs when NO_PTHREADS is definedJeff Hostetler via GitGitGadget, May 18, 2021
  2. Junio C HamanoMay 19, 2021
  3. Jeff HostetlerMay 19, 2021
  4. Junio C HamanoMay 19, 2021
  5. simple-ipc: correct ifdefs when NO_PTHREADS is definedJeff Hostetler via GitGitGadget, May 20, 2021
  6. Jeff HostetlerMay 20, 2021
  7. simple-ipc: correct ifdefs when NO_PTHREADS is definedJeff Hostetler via GitGitGadget, May 20, 2021
  8. Junio C HamanoMay 20, 2021

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.