[cfe-commits] [PATCH] stddef.h: redefine offsetof macro every time the header is included

Joerg Sonnenberger joerg at britannica.bec.de
Wed Apr 25 16:35:16 PDT 2012

On Wed, Apr 25, 2012 at 05:19:42PM +0400, Evgeniy Stepanov wrote:
> Hi,
> this patch moves offsetof definition outside of the header guard in
> Clang stddef.h header. As a result, it will override any conflicting
> definition of this macro every time stddef.h is included.
> On linux there is a conflicting definition in
> /usr/include/linux/sysdef.h, which, unlike Clang definition, is not a
> compile-time constant. Failing to override it with Clang definition
> breaks some code that otherwise (i.e. with GCC) compiles.
> This mimics GCC header behaviour which also redefines offsetof
> everytime it is included.
> Since this is a compiler header, we don't need #undef to override an
> earlier definition.
> Please review.

I don't like this. Frankly, why should the compiler have to workaround
broken (kernel?) header files? More importantly, this should at least
undef the macro first...


More information about the cfe-commits mailing list