This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: why are we not using const?
- From: Theodore Papadopoulo <Theodore dot Papadopoulo at sophia dot inria dot fr>
- To: Manuel López-Ibáñez <lopezibanez at gmail dot com>
- Cc: gcc at gnu dot org
- Date: Tue, 27 Jun 2006 17:02:40 +0200
- Subject: Re: why are we not using const?
- References: <6c33472e0606270551i1d5abe04j9d6c9839219539e8@mail.gmail.com>
- Reply-to: Theodore dot Papadopoulo at sophia dot inria dot fr
On Tue, 2006-06-27 at 13:51 +0100, Manuel LÃpez-IbÃÃez wrote:
> from comments in the #gcc irc channel, I understood that it is not
> advisable for gcc patches to use the const qualifier in function
> prototypes. I would like to understand why. Apart from its main
> purpose, I believed that the use of 'const' helps the compiler to
> optimise the code. Of course, I must be wrong, or the gains must be
> very small compared with the reasons for not using 'const', which I
> ignore.
More than optimization, I think const is good for documentation. It
shows at a glance what is supposed to change in the parameters of a
function. Not that it gives you garanties, but at least it reflects the
intent of the programmer.
Theo.