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

Evgeniy Stepanov eugeni.stepanov at gmail.com
Thu Apr 26 02:26:23 PDT 2012


Because that's how things work.

This header also does not fully respect __need_size_t and friends,
even though it should. This is a (undocumented) contract between gcc
and glibc headers. As we replace one part of the system, we are
responsible to do all the necessary hacks to maintain compatibility.

I don't mind adding an #undef, but it is absolutely unnecessary.

On Thu, Apr 26, 2012 at 3:35 AM, Joerg Sonnenberger
<joerg at britannica.bec.de> wrote:
> 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...
>
> Joerg
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits



More information about the cfe-commits mailing list