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