# [REGRESSION] cache.h in 2.41.0 uses undefined macros DT_*

3 messages from 2023-08-21 to 2023-08-21. Participants: Osipov, Michael (IN IT IN), Junio C Hamano.
Thread: https://gitlist.dev/t/60136

## Osipov, Michael (IN IT IN), 2023-08-21 12:37

Subject: [REGRESSION] cache.h in 2.41.0 uses undefined macros DT_*
Message-ID: <627378df-4655-4a8a-abcb-c15ab6602101@siemens.com>
URL: https://gitlist.dev/e/627378df-4655-4a8a-abcb-c15ab6602101%40siemens.com

```
Folks,

I am migrating from 2.37.1 to 2.41.0 on HP-UX. My compiler gives me the 
following:
> "cache.h", line 147: error #2020: identifier "DT_REG" is undefined
>                 return DT_REG;
>                        ^
> 
> "cache.h", line 149: error #2020: identifier "DT_DIR" is undefined
>                 return DT_DIR;
>                        ^
> 
> "cache.h", line 151: error #2020: identifier "DT_LNK" is undefined
>                 return DT_LNK;
>                        ^
> 
> "cache.h", line 153: error #2020: identifier "DT_UNKNOWN" is undefined
>                 return DT_UNKNOWN;
>                        ^
> 
> 4 errors detected in the compilation of "add-interactive.c".
> gmake: *** [Makefile:2715: add-interactive.o] Error 2

HP-Ux does not define these non-POSIX [1] macros while dir.h perfectly 
defines them. Tried from 2.40.0 tarball and it works flawlessly. So 
looking at [2] it is an oversight when treewide header cleanups have 
been performed. Including dir.h in cache.h does not work because it will 
cause duplicate definition of struct dir_entry.

For now, I did:
> diff -u -ur cache.h cache.h
> --- cache.h	2023-06-01 09:03:05 +0200
> +++ cache.h	2023-08-21 11:24:07 +0200
> @@ -91,6 +91,20 @@
>  struct pathspec;
>  struct tree;
>  
> +#if defined(DT_UNKNOWN) && !defined(NO_D_TYPE_IN_DIRENT)
> +#define DTYPE(de)	((de)->d_type)
> +#else
> +#undef DT_UNKNOWN
> +#undef DT_DIR
> +#undef DT_REG
> +#undef DT_LNK
> +#define DT_UNKNOWN	0
> +#define DT_DIR		1
> +#define DT_REG		2
> +#define DT_LNK		3
> +#define DTYPE(de)	DT_UNKNOWN
> +#endif
> +
>  /*
>   * Copy the sha1 and stat state of a cache entry from one to
>   * another. But we never change the name, or the hash state!

which is not a solution because this duplicates this block. Maybe a new 
header file should contain these cross-used macros?

At least git now compiles and works flawlessly for me on HP-UX.

Regards,

Michael

[1] https://stackoverflow.com/a/46694526/696632
[2] https://github.com/git/git/compare/v2.40.0...v2.41.0

```

## Junio C Hamano, 2023-08-21 16:19

Subject: Re: [REGRESSION] cache.h in 2.41.0 uses undefined macros DT_*
Message-ID: <xmqqmsykqsep.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqmsykqsep.fsf%40gitster.g
In-Reply-To: <627378df-4655-4a8a-abcb-c15ab6602101@siemens.com>

```
I think [*1*] on June 6th fixed it, and the fix has been in 'master'
for the last 2 months, and has been in the release candidate releases
for 2.42 that have been issued in the past weeks.

Thanks.

[Reference]

*1* https://lore.kernel.org/git/20230606205935.3183276-1-asedeno@google.com

```

## Osipov, Michael (IN IT IN), 2023-08-21 19:05

Subject: Re: [REGRESSION] cache.h in 2.41.0 uses undefined macros DT_*
Message-ID: <ed291567-2c47-40f9-bcf0-89bbd6b4b49c@siemens.com>
URL: https://gitlist.dev/e/ed291567-2c47-40f9-bcf0-89bbd6b4b49c%40siemens.com
In-Reply-To: <xmqqmsykqsep.fsf@gitster.g>

```
On 2023-08-21 18:19, Junio C Hamano wrote:
> I think [*1*] on June 6th fixed it, and the fix has been in 'master'
> for the last 2 months, and has been in the release candidate releases
> for 2.42 that have been issued in the past weeks.
> 
> Thanks.
> 
> [Reference]
> 
> *1* https://lore.kernel.org/git/20230606205935.3183276-1-asedeno@google.com

That's exactly it!

Just downloaded fresh 2.42.0 release tarball and it worked instantly.

Issue solved,

Regards,

Michael

```
