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

Evgeniy Stepanov eugeni.stepanov at gmail.com
Thu Apr 26 03:38:27 PDT 2012


On Thu, Apr 26, 2012 at 2:23 PM, Joerg Sonnenberger
<joerg at britannica.bec.de> wrote:
> On Thu, Apr 26, 2012 at 01:26:23PM +0400, Evgeniy Stepanov wrote:
>> Because that's how things work.
>
> The classic definition of offsetof is valid C. As long as you don't deal
> with C++, using __builtin_offsetof is optional. As such, this would
> trigger redef warnings on valid code.

AFAIK, there can be no redef warnings in a compiler header.

>
>> 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.
>
> Not everyone uses glibc. Your changes should not create regressions for
> other supported platforms. Of course, most other platforms do provide a
> sane stddef.h that works with the rest of the system headers.

Do you know where this will cause a regression? For the record, gcc
header stddef.h also redefines offsetof every time it is included.


>
> 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