Re: Why is argv not pointing to const?
- From: Eric Sosman <esosman@xxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 02 Mar 2008 09:19:43 -0500
Keith Thompson wrote:
Martin <martindotunderscoreobrien@xxxxxxxxxx> writes:On Sat, 01 Mar 2008 21:43:34 -0000, Keith Thompson <kst-u@xxxxxxx> wrote:Probably lint (note that there are a number of lintI get the same message from Lint.
implementations) is issuing this message because
your code didn't happen to modify these pointers.
What happens if you change your function's name
from "main" to something else?
I am using PC-lint for C/C++ (NT) Ver. 8.00L, with the options -W
-ansi -pedantic -Wall.
So it looks like PC-lint is recommending that anything that your code
doesn't happen to modify should be declared as const (not bad advice
IMHO), but it's not allowing for the fact that the "main" function is
a special case.
Seems to me that `const' is appropriate only if the
non-modification is part of the "contract" or "interface"
of the function. The fact that today's version of the
function doesn't modify something is not necessarily a
promise that tomorrow's version will do likewise. Take
lint's advice as advice, not as a command.
In fact, that's the way to approach all of lint's
advice. Lint's job is to be a Nervous Nellie, to see a
lurking felon in every shadow and a goblin hiding beneath
every bed. Many of the felons and goblins will turn out
to be imaginary, but it behooves you to shine a few lights
in the shadows and poke under the beds with broomsticks,
just in case. See also the First Commandment at
http://www.lysator.liu.se/c/ten-commandments.html
--
Eric Sosman
esosman@xxxxxxxxxxxxxxxxxxxx
.
- Follow-Ups:
- Re: Why is argv not pointing to const?
- From: Martin
- Re: Why is argv not pointing to const?
- References:
- Why is argv not pointing to const?
- From: Martin
- Re: Why is argv not pointing to const?
- From: Keith Thompson
- Re: Why is argv not pointing to const?
- From: Martin
- Re: Why is argv not pointing to const?
- From: Keith Thompson
- Why is argv not pointing to const?
- Prev by Date: Re: printf("%f") question
- Next by Date: Re: function
- Previous by thread: Re: Why is argv not pointing to const?
- Next by thread: Re: Why is argv not pointing to const?
- Index(es):
Relevant Pages
|