Re: [cc65] Variables + Local Static

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2007-08-21 14:29:42
Hi!

On Tue, Aug 21, 2007 at 12:59:51PM +0200, Christian Krüger wrote:
> is this bug releated to the problem that:
>
> int
> test(int in)
> {
>   static int val = in*2;
>   return val;
> }
>
>
> does not compile? (constant expression expected)

No. This is not legal C. Think about it yourself: static variables are
intialized at compile time and keep their values between function calls. How
can this work with above code? 

Besides that, this is what gcc says:

uz@trixie:~$ gcc -Wall -o t t.c
t.c: In function ‘test’:
t.c:8: error: initializer element is not constant

> Beside this, can you give me a hint on the issue I posted
> on 2007-07-08 21:13:34 (ca65: Problem with generic labels...)???

Sorry, I have lots of mails to keep up with.

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz@musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Tue Aug 21 14:29:53 2007

This archive was generated by hypermail 2.1.8 : 2007-08-21 14:29:56 CEST