Hi Bruno,

On 5/18/24 4:12 AM, Bruno Haible wrote:
> While testing a testdir for module 'endian' on gcc110.fsffrance.org
> (in the GCC compilefarm), I get a compilation error. This machine has
> a pretty old libc (glibc 2.17), but that ought to work anyway.

Oops, sorry.

I sent a request for a compile farm account today since I realized I
have no way of testing other architectures (other then VMs I guess).

> In other words: When overriding a system header, you must conditionally
> #include_next that system header. (There are exception to this rule,
> such as <glob.h> or <obstack.h>. But in general this rule is valid.)
> The system header can have made any number of additional definitions
> or declarations, and other system headers (and user code) may rely on
> these definitions or declarations.

I see. What is the correct solution here? I guess you could define
__MACROS but that is a bit hacky in my opinion.

Maybe defining a macro for ALMOST_WORKING_ENDIAN_H (i.e. missing types).

Or something like this:

#if @HAVE_ENDIAN_H@
# @INCLUDE_NEXT@ @NEXT_ENDIAN_H@
#endif

/* Undefine macros.  */
#undef betoh16
#undef betoh32
#undef betoh64
[....]

/* Override them if they are functions.  */
#define betoh16 __gl_betoh16
#define betoh32 __gl_betoh32
#define betoh64 __gl_betoh64

I haven't ever used the '#include_next' directive so I am just basing
this off of what I have seen in Gnulib.

Collin

Reply via email to