Pages: [1]   Go Down
Author Topic: Arduino 0011 and <stdio.h>  (Read 1171 times)
0 Members and 1 Guest are viewing this topic.
Underhill Center, Vermont, USA
Offline Offline
Jr. Member
**
Karma: 0
Posts: 71
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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



Logged

Bangalore, India
Offline Offline
Jr. Member
**
Karma: 0
Posts: 77
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#undef int
#include <stdio.h>

Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 12
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Underhill Center, Vermont, USA
Offline Offline
Jr. Member
**
Karma: 0
Posts: 71
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

 cheers ... BBR
Logged

Pages: [1]   Go Up
Jump to: