This is the mail archive of the gcc@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: Using C++ in GCC is OK


On Mon, May 31, 2010 at 7:22 AM, Robert Dewar <dewar@adacore.com> wrote:
> One interesting issue is whether it is important for gcc to be
> able to be compiled with foreign compilers (other than gcc).
>
> I know that historically this has been an important requirement,
> but I wonder whether it is still relevant.
>
> Gcc is very widespread at this point. Yes, there is the issue
> of completely new targets, but these can be easily handled by
> building cross-compilers.
>
> I suspect that the use of C++ will make the use of foreign
> compilers harder, but I suspect also that it doesn't matter.

I do not think so, and I would not suggest that the use of C++ is an excuse
do ditch the possibility of bootstrapping with anything other than GCC.

As for the subset of C++ to use, yes we need to be conservative.  A very
large part of C++98 is well established.  Although it would be tempting, I would
recommend against using it as with "C with classes".  We should be able to use:

   * classes with multiple access protection sections (i.e. public sectionsfor
       interface operations, private section for data members that should not be
       accessed directly, etc.)
   * full single inheritance
   * multiple inheritance where appropriate, but NOT virtual inheritance
   * namespaces to partition codes.  Prefer explicit qualification over
      reliance on argument dependent name lookup (except for
operators, of course)
    * simple templates -- e.g. containers, simple functions, but avoid creative
       uses such as template metaprogramming.
    * avoid casts, and dynamic_cast should be kept to the minimum -- use of
       virtual functions should be preferred (as we currently do with hooks).
    * trust the reviewers to use the best judgments.


-- Gaby


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