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 */

}

As You have counter variable with char datatype. But its not an array or string.

  so you can't access it by counter[1].

Need Your Help

Solver for sparse linearly-constrained non-linear least-squares

solver sparse-matrix least-squares nonlinear-optimization

Are there any algorithms or solvers for solving non-linear least-squares problems where the jacobian is known to always be sparse, and the solution is constrained with either:

Can a class with getters separate from input processing methods be considered “thread-safe”?

java concurrency thread-safety

I was reading though a book on Java and there was this exercise question where they declared a class with one private variable, one public void method that did some expensive operation to calculate...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.