This is the mail archive of the 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: const warning...

On 04-Jul-2003, Theodore Papadopoulo <> wrote:
> The idea would be to add a -W flag (yet unnamed)


> that will try to 
> help the user in identifying the places where a const qualifier 
> could be added (this can be for variables and also for methods in 
> C++). This might help a lot in constifying a code (even thought I'm 
> trying to constify from the beginning), or completing the 
> constification of a code.

Given a pointer declaration such as
	char * p;

it is far more useful to add a const qualifier on the pointed-to type, i.e.

	char const * p;

rather than adding a const qualifier on the variable's type, i.e.

	char * const p;

Adding "const" on local variable definitions that happen to only be set
once is not especially useful for documentation or maintenance purposes.
But adding "const" on pointer targets is very useful for documentation
and maintenance.  I would much prefer a warning for missing const on
pointer targets than for missing const on variable definitions.

Fergus Henderson <>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <>  |     -- the last words of T. S. Garp.

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