Subject: Re: [PATCH] meson: ensure correct version-def.h is used

From: Patrick Steinhardt <[email-masked]>
Date: Tue, 14 Jan 2025 07:52:07 +0100

On Mon, Jan 13, 2025 at 06:24:04PM +0100, Toon Claes wrote:
> Junio C Hamano <[email-masked]> writes:
> 
> > What happens if we use <version-def.h> to include (which is how C
> > standard tells us to do), with an explicit include path specified
> > with -I<directory>?  If it solves the issue, that may be a better
> > approach.
> 
> I don't have a good source, but for example Wikipedia[1] says:
> 
>     Some preprocessors locate the include file differently based on the
>     enclosing delimiters; treating a path in double-quotes as relative
>     to the including file and a path in angle brackets as located in one
>     of the directories of the configured system search path.
> 
> So behavior seems to depend on the implementation of the compiler. I'm
> not sure we can trust all architectures to do what we expect.

Even if we could it still feels somewhat fragile. The top-level source
directory gets added to our include paths, as well, and consequently it
may also be found via <version-def.h>. So things would depend on the
order of "-I" directives now. Which makes me lean into the direction of
my proposed workaround, to optionally inject an absolute path.

> Or, because I don't expect many people to use Make and Meson at the
> same time, do we not consider this an issue for most anyway?

In the current phase I think it's still quite likely that people use
both at the same time, so fixing it would be nice.

Patrick