Re: [cc65] # of local variables allowed?

Date view Thread view Subject view

From: M Ancher (ancher_at_ancher.org)
Date: 2003-03-01 13:14:18


On Fri, Mar 02, 2001 at 07:45:37PM +0100, Ullrich von Bassewitz wrote:
>> 	When trying to compile I get the error "Too many local variables".

> The limit is 256 bytes total (parameters + locals + space for temporaries).
> The reason is that the stack is addressed using the Y register. Working around
> it would generate really awful code, since lots of additional calculations at
> runtime are needed.				

> If your program has no recursive code. switching to static locals (via the
> --static-locals compiler switch) will usually fix the problem. Using static or
> dynamic memory (malloc/free) would be other possible solutions.

I thought I'd reply to a very old answer, since it's the same trouble I
have now.

The above almost answers it all.

Since I have two functions which are recursive, I cannot just use the
»--static-locals«-switch on all code. I thought about moving the
recursive code into another ».c«-file and compile that without
»--static-locals«. (It could be linked later, right?)

This is one option, but is it better to:

I could move the functions that gives the error »Too many local
variables« into another ».c«-file. This way only the »troublesome« code
is compiled with »--static-locals«. This solution would save more memory
at runtime, since it will only allocate memory when needed, right?

-- 
Martin Ancher <ancher_at_ancher.org>
http://ancher.org/
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2003-03-01 13:15:48 CET