This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Factor unrelated declarations out of tree.h (2/2)
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Andrew MacLeod <amacleod at redhat dot com>
- Cc: "Joseph S. Myers" <joseph at codesourcery dot com>, Diego Novillo <dnovillo at google dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 15 Nov 2013 15:14:17 +0100
- Subject: Re: Factor unrelated declarations out of tree.h (2/2)
- Authentication-results: sourceware.org; auth=none
- References: <20131114204044 dot GA8148 at google dot com> <Pine dot LNX dot 4 dot 64 dot 1311142213190 dot 16398 at digraph dot polyomino dot org dot uk> <52858BA7 dot 2040006 at redhat dot com> <CAFiYyc1FF7r0P8kwANH-Sy38Ar05nacqLjQOZ_sjiaNBuQ+mmA at mail dot gmail dot com> <Pine dot LNX dot 4 dot 64 dot 1311151320470 dot 29859 at digraph dot polyomino dot org dot uk> <5286242E dot 4050909 at redhat dot com>
On Fri, Nov 15, 2013 at 2:39 PM, Andrew MacLeod <amacleod@redhat.com> wrote:
> On 11/15/2013 08:31 AM, Joseph S. Myers wrote:
>>
>> On Fri, 15 Nov 2013, Richard Biener wrote:
>>
>>> Yeah, though this has interesting effects on includes that do stuff like
>>>
>>> #ifdef NO_DOLLARS_IN_LABELS
>>> ...
>>>
>>> where the presence of this definition depends on another header file
>>> and thus the ultimate outcome in your .c file depends on include file
>>> order.
>>>
>>> So ... no #ifdefs inside headers? Or have meta-defines like
>>>
>>> #define NO_DOLLARS_IN_LABELS_DEFINED
>>>
>>> and
>>>
>>> #ifndef NO_DOLLARS_IN_LABELS_DEFINED
>>> #error ...
>>> #endif
>>>
>>> at use sites?
>>
>> Rather than such a meta-define, I prefer changing the semantics of the
>> macro itself from defined/undefined to nonzero/zero, changing the users
>> from #if to if () conditionals (or ? :, as appropriate), and adding a
>> default zero definition to defaults.h along with updating all definitions,
>> users and documentation. A meta-define seems just as error-prone as the
>> original #ifdef.
>
> I like this a lot actually.... then you can tell whether its been defined or
> not... Although I suppose it depends on when and where the non-default value
> comes from, and that it is properly included in the .c file and not missed.
> It ought to cover the vast majority of cases anyway.
>
>>
>> Similarly, for any macros with default definitions scattered around the
>> source tree rather than in defaults.h, moving them to defaults.h is a good
>> idea.
>
> I think this is also a good idea.
Or you move the macros depending on NO_DOLLARS_IN_LABELS
to tm.h itself ...
Richard.
> Andrew
>