![]() |
|
Message-ID: <CO6PR11MB5602969F75FD87D144CF6AFEEDEEA@CO6PR11MB5602.namprd11.prod.outlook.com> Date: Thu, 9 Oct 2025 02:53:13 +0000 From: "Chen, Qi" <Qi.Chen@...driver.com> To: Rich Felker <dalias@...c.org> CC: "musl@...ts.openwall.com" <musl@...ts.openwall.com> Subject: RE: [PATCH 2/2] include/netinet/if_ether.h: guard ethhdr definition to better work with other header files Hi Rich, The problem is about the re-definition of 'struct ethhdr'. For example, a header also defines 'struct ethhdr' and __UAPI_DEF_ETHHDR, and it's included *before* our <netinet/if_ether.h>, then the unconditional definition of 'struct ethhdr' in this header will be treated as an error. Some background info: I was making systemd to compile with musl. I got this re-definition error. I checked the headers and thought that for different headers to work together, the definition of this 'struct ethhdr' needs to be guarded by the same macro. Regards, Qi -----Original Message----- From: Rich Felker <dalias@...c.org> Sent: Tuesday, September 30, 2025 9:34 PM To: Chen, Qi <Qi.Chen@...driver.com> Cc: musl@...ts.openwall.com Subject: Re: [musl][PATCH 2/2] include/netinet/if_ether.h: guard ethhdr definition to better work with other header files On Tue, Sep 30, 2025 at 10:45:38AM +0800, Qi.Chen@...driver.com wrote: > From: Chen Qi <Qi.Chen@...driver.com> > > The unconditional definition of 'struct ethhdr' has the implicit > requirement on this header file, that is, it needs to be included > before other header files defining ethhdr. > > Signed-off-by: Chen Qi <Qi.Chen@...driver.com> > --- > include/netinet/if_ether.h | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/include/netinet/if_ether.h b/include/netinet/if_ether.h > index b1646f6f..e5a1ebd0 100644 > --- a/include/netinet/if_ether.h > +++ b/include/netinet/if_ether.h > @@ -112,12 +112,14 @@ > #define ETH_P_XDSA 0x00F8 > #define ETH_P_MAP 0x00F9 > > +#ifndef __UAPI_DEF_ETHHDR > struct ethhdr { > uint8_t h_dest[ETH_ALEN]; > uint8_t h_source[ETH_ALEN]; > uint16_t h_proto; > }; > #define __UAPI_DEF_ETHHDR 0 > +#endif > > #include <net/ethernet.h> > #include <net/if_arp.h> > -- > 2.34.1 Defining a macro multiple times with the exact same token sequence as its definition each time is not an error.
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.