MPLab / C prg / Variables

I have MPLab V8.43 installed and just installed the C18 complier for programming. Whenever I try and build a small test code it halts at the first variable declaration. It says there is a syntax.

unsigned char counter;

doesn't look wrong to me...even did it as unsigned char counter[1]; and it still tossed a syntax error back at me. What gives? Any ideas?

Answers


Local variables must be declared at the top of a block (in this case, a function.) This is according to the C89 standard.

These are acceptable:

void functionname(void)
{
    unsigned char counter;

    /* rest of code */
}

void functionname(void)
{
    /* code */

    for (unsigned char counter = 0; counter<30; counter++)
    {
    }

}

This is not acceptable:

void functionname(void)
{
    /* code */

    unsigned char counter = 0; 

    /* more code */

}

Need Your Help

How do I reference SSIS on a build machine without installing SQL Server 2008 Client Tools?

sql-server configuration ssis build-automation

I need to build SSIS packages on a build machine, and do not want the overhead of installing SQL Server Management Studio on this machine. A SQL Server 2008 SDK would be ideal, but I could not find...

How can I obtain the coordinates of a selected item container in a WPF ListView

wpf listview coordinates selecteditem

I want to display some WPF elements near to the selected item of a ListView. How can I obtain the coordinates (screen or relative) of the selected ListViewItem?