Bug declaring a byte

Hi!

I have an erratic problem.

In the middle of a program, when declaring a byte a the beginning of a function :

byte maskByte = 0x7f;

I get this compilation error:

expecting RCURLY, found 'byte'

It hapened before, and after randomly cutting, pasting, re-editing and leaving it the same, it suddenly compiled. :o

Now it has happened again elsewhere....

Does somebody know what could this be?

Thaaaaaaaanx a lot!

Cristina

More details:

I had some printStatements before the declaration (cx, and cy are passed to the function when calling):

printString ("coord x to deactivate = "); printBinary(binary2decimal(cx)); printNewline(); printString ("coord y to deactivate = "); printBinary(binary2decimal(cy)); printNewline();

If I erase them all (I have tried all kinds fo combinations erasing just some of them) it suddenly compiles !

:o

I have the same kind of print statement afterwards and that doesn't give problems...

It must be something really stupid but I can't understand what it is....

Lots of good questions, Cristina. We need to include more information about C in the Arduino reference. In this case the problem is that C only lets you declare variables at the beginning of a function or block (basically any use of curly braces, like for() {} or if() {}) or globally, outside of any functions. You need to put the print statements after the variable declaration. In Arduino 0004, the main sketch will be compiled as C++, allowing variable declarations to appear anywhere.

Hi Dave!

Thanx a lot for all your answers!!!! You have helped me clarify a lot of stuff!!

I am totally ashamed about my C.... I should seriously study a manual...

Hope it helped others anyway!

Cheers!

Cristina