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

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

From
Osipov, Michael (IN IT IN) <michael.osipov@siemens.com>
Date
Aug 21, 2023, 12:37 UTC
Message-ID
<627378df-4655-4a8a-abcb-c15ab6602101@siemens.com>
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

Next: Junio C Hamano
Message 1 of 3 in “[REGRESSION] cache.h in 2.41.0 uses undefined macros DT_*”
  1. Osipov, Michael (IN IT IN)Aug 21, 2023
  2. Junio C HamanoAug 21, 2023
  3. Osipov, Michael (IN IT IN)Aug 21, 2023

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.