Arduino 0011 and <stdio.h>

I was doing some coding to make use a printf and a test sample of code I had that compiled clean 0010, blew up in stdio.h under 0011. I gutted the code to bare bones:

#include <stdio.h> 
// char _str[32]; // 32 chars max! increase if required to avoid overflow 
// #define writeln(...) sprintf(_str, __VA_ARGS__); Serial.println(_str) 

void setup() {
}

void loop() {
}

and it produced these errors. Anyone know what’s going on here?

Cheers … BBR

/Applications/arduino-0011/hardware/tools/avr/bin/…/lib/gcc/avr/4.0.2/…/…/…/…/avr/include/stdio.h:266: error: expected unqualified-id before ‘int’

/Applications/arduino-0011/hardware/tools/avr/bin/…/lib/gcc/avr/4.0.2/…/…/…/…/avr/include/stdio.h:266: error: expected `)’ before ‘int’

/Applications/arduino-0011/hardware/tools/avr/bin/…/lib/gcc/avr/4.0.2/…/…/…/…/avr/include/stdio.h:266: error: expected `)’ before ‘int’

/Applications/arduino-0011/hardware/tools/avr/bin/…/lib/gcc/avr/4.0.2/…/…/…/…/avr/include/stdio.h:267: error: expected unqualified-id before ‘int’

/Applications/arduino-0011/hardware/tools/avr/bin/…/lib/gcc/avr/4.0.2/…/…/…/…/avr/include/stdio.h:267: error: expected `)’ before ‘int’

/Applications/arduino-0011/hardware/tools/avr/bin/…/lib/gcc/avr/4.0.2/…/…/…/…/avr/include/stdio.h:267: error: expected `)’ before ‘int’

/Applications/arduino-0011/hardware/tools/avr/bin/…/lib/gcc/avr/4.0.2/…/…/…/…/avr/include/stdio.h:420: error: ‘__put’ was not declared in this scope

/Applications/arduino-0011/hardware/tools/avr/bin/…/lib/gcc/avr/4.0.2/…/…/…/…/avr/include/stdio.h:420: error: expected primary-expression before ‘char’

/Applications/arduino-0011/hardware/tools/avr/bin/…/lib/gcc/avr/4.0.2/…/…/…/…/avr/include/stdio.h:420: error: expected primary-expression before ‘struct’

/Applications/arduino-0011/hardware/tools/avr/bin/…/lib/gcc/avr/4.0.2/…/…/…/…/avr/include/stdio.h:420: error: ‘__get’ was not declared in this scope

/Applications/arduino-0011/hardware/tools/avr/bin/…/lib/gcc/avr/4.0.2/…/…/…/…/avr/include/stdio.h:420: error: expected primary-expression before ‘struct’

/Applications/arduino-0011/hardware/tools/avr/bin/…/lib/gcc/avr/4.0.2/…/…/…/…/avr/include/stdio.h:420: error: initializer expression list treated as compound expression

Couldn’t determine program size: hardware/tools/avr/bin/avr-size: ‘/tmp/build47599.tmp/sketch_080618a.hex’: No such file

it’s to do with the redefinition of ‘int’ IIRC… something being tried out in v11 .

Mellis posted about this as soon as v11 came out, but I can’t seem to find the posting at present.

undefining the int macro before the include will fix it…

#undef int
#include <stdio.h>

Yes, we #define int(x) as ((int) (x)) in Arduino 0011 so people can use a function-like syntax to cast things. Unfortunately, this breaks a function pointer definition in stdio.h. In Arduino 0012, the #include <WProgram.h> (which defines int()) will be moved after your #includes, so this shouldn’t be a problem. In the meantime, mungbean’s suggestion should work.

Thanks guys, mungbean's suggestion cleaned things up nicely.

cheers ... BBR