comp.lang.ada
 help / color / mirror / Atom feed
From: Peter Chapin <PChapin@vtc.vsc.edu>
Subject: Re: actual for variable name must be variable compiler error
Date: Tue, 30 Sep 2014 08:09:19 -0400
Date: 2014-09-30T08:09:19-04:00	[thread overview]
Message-ID: <APSdnd0ZoODtALfJnZ2dnUVZ57ydnZ2d@giganews.com> (raw)
In-Reply-To: <m0cte9$58d$1@dont-email.me>

On 2014-09-29 20:27, Simon Clubley wrote:

> However, I want to make it clear I don't write production code like
> that. If an in parameter needs modifying in a C program it gets copied
> into a local variable and worked on there. Modifying an in parameter
> in the way it's done in my example just feels so very wrong to me even
> when the language lets you do it...

In C parameters have the same status as local variables. If it is
convenient to modify it, then I modify it just as I might modify a
local. If it is not something to be modified one can declare it const as
with any local

void f(const int x)
{
    x = 5;   // Error. Modifying a const.
}

I use a tool (PC-Lint) that can be configured to remind me whenever a
parameter could be declared const. I generally try to follow its advice
in this area.

Peter



  reply	other threads:[~2014-09-30 12:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-29  0:48 actual for variable name must be variable compiler error Stribor40
2014-09-29  2:50 ` Jeffrey Carter
2014-09-29 10:39 ` Brian Drummond
2014-09-29 19:37   ` Simon Clubley
2014-09-29 21:33     ` Georg Bauhaus
2014-09-30  0:27       ` Simon Clubley
2014-09-30 12:09         ` Peter Chapin [this message]
2014-09-30 13:17         ` Dennis Lee Bieber
2014-09-30 19:48           ` Simon Clubley
2014-09-30 14:47         ` Adam Beneschan
2014-09-29 14:27 ` Denis McMahon
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox