Go Down

Topic: Arduino 0011 and <stdio.h> (Read 1 time) previous topic - next topic

brianbr

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:
Code: [Select]
#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

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





mungbean

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...

Code: [Select]

#undef int
#include <stdio.h>



mellis

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.

brianbr

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

cheers ... BBR

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy