This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Compiling GCC With a C++ Compiler (g++)
- From: Andreas Schwab <schwab at suse dot de>
- To: "Dave Korn" <dk at artimi dot com>
- Cc: "'Gabriel Dos Reis'" <gdr at cs dot tamu dot edu>,"'Phil Edwards'" <phil at codesourcery dot com>,"'Zack Weinberg'" <zack at codesourcery dot com>,"'Geoffrey Keating'" <geoffk at apple dot com>,"'Ranjit Mathew'" <rmathew at gmail dot com>, <gcc at gcc dot gnu dot org>
- Date: Wed, 13 Oct 2004 17:33:07 +0200
- Subject: Re: Compiling GCC With a C++ Compiler (g++)
- References: <NUTMEGwbYhesq37xpVc0000044e@NUTMEG.CAM.ARTIMI.COM>
"Dave Korn" <dk@artimi.com> writes:
> The problem was in refactoring a huge amount of legacy code that used a
> vast number of global variables. To try and modularise and data-hide it
> somewhat I wanted them all to become local to a single module, with accessor
> functions visible to the rest of the application. So I declared them all
> "extern CONST" in a header file. When a client module wanted to include the
> header file, it got CONST defined as "const", but when the same header was
> included by the module that instantiated the variables, CONST was defined to
> nothing. This allowed me to simulate protected class member variables, but
> had the aforementioned consequence on the optimiser.
IMHO this is a rather different situation. Since the declaration says
const the compiler can assume that the definition also says const (since
they must match), and that the object is really read-only.
On some platforms such a program may even fail to compile because the
method to access read-only objects may be incompatible that of writable
objects.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."