[cc65] declaring variables after code

From: Steve Davison <64subnet1gmail.com>
Date: 2010-04-23 00:54:31
I just deduced that cc65 does not allow variables to be defined
in a scope after code has been encountered...  as illustrated in
this nonsense code:


void func( int var)
{
    int temp;
    int tot = 1;
    tot += var;                     // First code
    temp = tot - var;

    int i;       // new bss var (line 75)... ERROR (see below)
    for (i = 0;  i < temp;  ++i)
        ++tot;

    // This is also a problem, even if it's at the top of
    // the function
    for (int x=0;  x<3;  ++x)
        ;
}


MAIN.C(75): Error: Expression expected
MAIN.C(75): Warning: Statement has no effect
MAIN.C(75): Error: `;' expected
MAIN.C(75): Error: Undefined symbol: `i'

I haven't found  mention of this limitation in the docs or
archives, and it is valid in C99 standard.  It seems to make
it impossible to ever declare a variable in a for loop header,
even though that new variable has a scope internal to the loop.

What am I missing?
// Steve
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Fri Apr 23 00:54:48 2010

This archive was generated by hypermail 2.1.8 : 2010-04-23 00:54:50 CEST