This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [basic-improvements, committed] Split tm.h from config.h


Fergus Henderson <fjh@cs.mu.OZ.AU> writes:

> Zack Weinberg <zack@codesourcery.com> wrote:
>> 
>> Not true.  You just include the third-party library headers after
>> system.h.
>
> Hmm... that's not what you wrote above.  So now I'm confused.
> Which is it:
>
> 	(1) you must only include system headers if you have verified that
> 	    system.h does not
>
> or
>
> 	(2) it's OK to include system headers (either directly, or via
> 	    third-party headers) so long as they come after system.h

It's somewhere in between.  Let me attempt to articulate it:

  It's okay to include system headers directly, as long as they are
  not included by system.h, you put the #include directives after the
  one for system.h, and you use #ifdef wrappers if necessary.  (For
  a correct example, see timevar.c.)

  If you are interfacing to a third-party library, include its headers
  and don't worry about what system headers they might suck in, but do
  so after including system.h.  This may provoke 'poisoned identifier'
  errors; if so, bring up the problem on the list and we'll figure out
  what to do about it.  (No current in-tree examples.)

> That sort of stuff may be needed for the C front-end, which needs to
> support pre-C89 systems.  But for the Mercury front-end, we have no
> interest in supporting pre-C89 systems.  I don't see why Treelang
> needs to support pre-C89 libraries either.

It is still appropriate to code according to the prevailing idiom.
Also, even with a C89-compliant library as an assumption, there are
still portability issues that system.h insulates you from.

>> Well, there's your special need.  But I would encourage you to create
>> a header containing just those global register declarations, and
>> include only that header before system.h (not before config.h).
>
> That can't be done, or at least not easily, because the #include
> statement that includes the Mercury headers is automatically generated.
>
> The #include statements that include the GCC header files occur in a
> Mercury source file (as part of a C interfacing declaration).
> The Mercury compiler generates a C file which includes the
> Mercury headers, since they need to come first, followed by any
> C declarations needed for C interfacing code in the Mercury module
> being compiled -- in this case, the includes of the GCC headers.

I don't fully understand the setup here, but I wouldn't worry about it
too much as long as it keeps working.

zw


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]