Re: Why not auto?
- From: Chris Croughton <chris@xxxxxxxxxxxx>
- Date: Tue, 10 May 2005 14:59:22 +0100
On Tue, 10 May 2005 14:04:05 +0100, Lawrence Kirby
<lknews@xxxxxxxxxxxxxxx> wrote:
> On Mon, 09 May 2005 20:04:38 +0100, Chris Croughton wrote:
>
>> On Mon, 09 May 2005 13:29:27 GMT, Richard Bos
>> <rlb@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>>
>>> No storage class specifier except register can be used for function
>>> parameters declarations. Not auto, but not static, extern or typedef
>>> either. The reason, I suppose, is that declaring a function parameter to
>>> be extern or auto makes even less sense than declaring it register.
>>> Consider: whatever would it mean, a static function parameter?
>>
>> Treat it as a suggestion (like register) that the value should be held
>> in 'static' memory rather than stack, for optimisation? For instance,
>> on a system where stack space is limited declaring all local variables
>> including parameters as static (knowing that the function wouldn't be
>> reentrant) might be useful.
>
> This really boils down to a promise that the function won't be called
> recursively, or concurrently from a signal handler. This would make more
> sense as a attribute for the function as a whole rather than for
> particular parameters.
It might be needed only for certain parameters (long doubles and large
structs for instance) with others being in registers:
int doSomething(register int action, static struct data);
I agree that a function attribute would also be useful. It can't be yet
another use of static, though, how about restrict? That has a similar
meaning (promise the compiler that you aren't going to do something
'clever' and non-optimisable):
restrict int wellBehavedFunction(int x, double y);
(Some compilers used for embedded systems have had their own extensions
to do similar things...)
Chris C
.
- Follow-Ups:
- Re: Why not auto?
- From: Michael Mair
- Re: Why not auto?
- From: Lawrence Kirby
- Re: Why not auto?
- References:
- Why not auto?
- From: Vijay Kumar R. Zanvar
- Re: Why not auto?
- From: Richard Bos
- Re: Why not auto?
- From: Chris Croughton
- Re: Why not auto?
- From: Lawrence Kirby
- Why not auto?
- Prev by Date: obtaining the time offset from UTC
- Next by Date: Re: obtaining the time offset from UTC
- Previous by thread: Re: Why not auto?
- Next by thread: Re: Why not auto?
- Index(es):
Relevant Pages
|