threads / discuss / 60136

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

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

## tl;dr

3 messages between Aug 21, 2023 and Aug 21, 2023.

replies: 2people: 2as markdown or json

Osipov, Michael (IN IT IN)· Aug 21, 2023, 12:37 UTC · lore
Folks,

I am migrating from 2.37.1 to 2.41.0 on HP-UX. My compiler gives me the following:

Show 18 quoted lines
> "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:
Show 24 quoted lines
> 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· Aug 21, 2023, 16:19 UTC · re: Osipov, Michael (IN IT IN) · lore

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

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)· Aug 21, 2023, 19:05 UTC · re: Junio C Hamano · lore

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

On 2023-08-21 18:19, Junio C Hamano wrote:
Show 9 quoted lines
> 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

← back to recent threads