Re: Const qualifier conversion warnings
Re: Const qualifier conversion warnings
- Subject: Re: Const qualifier conversion warnings
- From: George Warner <email@hidden>
- Date: Sat, 04 Jun 2005 13:11:40 -0700
On Fri, 3 Jun 2005 20:22:56 +0100, "Theodore H. Smith" <email@hidden>
wrote:
> I did that before, and then decided against it because of the amount
> of work it was requiring from me.
This work is minor compared to debugging an unintentional modification to
what should be a const variable.
> I declare Left as const, but then Left calls another function to do
> it's work. So that needs to be defined const too. But then that
> function also calls other functions, and soon enough I'm having to
> rework my entire class, that was already totally valid, simply
> because of a complaining compiler.
The compiler is trying to save you from yourself. If a routine doesn't
modify a variable passed to it then it should be declared const. It's ok to
pass a non-const variable as a const (you shouldn't get a warning for this);
But it's not ok to pass a const as a non-const (since the routine should not
be able to modify a const variable).
> I see a compilers job as to be making my job easier. I know when code
> is correct or not, and I know that that code is correct at least as
> far as constness goes, so I'd like to be able to tell the compiler to
> not make my job harder by complaining about stuff that's fine.
About ever other week or so I receive a project that a developer wants me to
debug because they can't figure it out why it's crashing. The first thing I
do is turn all the warnings and errors back on and pay attention to what
they're saying. They weren't put there to annoy you. They're there to help
you write better code.
--
Enjoy,
George Warner,
Schizophrenic Optimization Scientist
Apple Developer Technical Support (DTS)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden