This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Go front end review: files outside gofrontend/
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Ian Lance Taylor <iant at google dot com>, gcc-patches at gcc dot gnu dot org
- Date: Sat, 6 Nov 2010 21:42:52 +0000 (UTC)
- Subject: Re: Go front end review: files outside gofrontend/
- References: <Pine.LNX.4.64.1011061757150.21929@digraph.polyomino.org.uk>
A further comment on go-system.h:
It is always necessary for code in GCC to include config.h before any
system headers. Thus, the includes
#include <string>
#include <vector>
#include <tr1/unordered_map>
#include <iostream>
#include <cstdio>
are unsafe because they appear before the include of config.h.
In particular, feature test macros such as those for large-files support
(which is now enabled in GCC) may be defined in config.h and may only be
effective if defined before any system headers are included - and C++
system headers may include C system headers.
If the issue described in
// These must be included before the #poison declarations in system.h.
arises then I think the answer is for system.h to include some C++
headers, when compiling as C++, before the problem #poison declarations,
just as it includes various C headers. A suitable set of C++ header
includes might also eliminate many of the #include <...> directives in
individual files in the front end. If a source file directly includes a
<...> system header, there should be a clear reason why that include is
not in system.h (for example, deliberately deciding that certain
interfaces such as those from GMP and MPFR should only be used in certain
parts of the compiler - especially where using a header may result in
library dependencies not desired for programs such as the driver).
--
Joseph S. Myers
joseph@codesourcery.com