Hi- gcc by default allows variables to be declared in the middle of
code eg.

int test(int x)
{
    x++;
    int y = x + 2; /* ok */
    return y;
}

But it doesn't appear to like them directly after case statements:

int test(int x)
{
    x++;
    int y = x + 2; /* ok */
    switch (x)
    {
    case 2:
        int z = x; /* error here */

error: syntax error before "int"

But if I insert an empty statement before the int:

    case 2:
        ; int z = x; /* ok now */

it's fine. I'm using gcc 3.4.6 under linux - is this a peculiarity of
this compiler, or version of the compiler, or something else?

Cheers
John

Reply via email to