stdio? sprintf?

Can you use the stdio.h provided functions like sprintf? Seems like that’d be an awfully nice way to build output strings. Since the compiler is basically avr-gcc, I’d think it would work. But when I do things like:

#include <stdio.h>

void setup() { }
void loop() { }

and test compile, I get:

/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

:frowning:

The solution is posted in a few threads including this : http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1207028702

You can often find an answer to common arduino compile errors like this one by putting the error message and the keyword arduino into a google search, for example: arduino error: expected `)' before 'int'

Since the compiler is basically avr-gcc, I'd think it would work.

--Phil.

The solution is posted in a few threads including this : http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1207028702

You can often find an answer to common arduino compile errors like this one by putting the error message and the keyword arduino into a google search, for example: arduino error: expected `)' before 'int'

Ha! google.. and that's what I always tell other people to do! :-[. Thanks for the pointer, that fixed the problem. And here I went and figured, 'well avr-gcc 4.0.1 is a pretty old GCC version.. let's go get 4.3.1.

I've built many a GCC package in my 13 years as a Solaris admin... and I've never once attempted a cross-compilation. I gotta tell ya, getting 4.3.1 to build for the avr from my Intel Mac is a freaking nightmare! Whoever provided the 4.0.1 binaries -- my hat is off to you! Your gcc-fu is way better'n mine!

Kudos to provider(s) of ALL the avr-gcc binaries for that matter, regardless of the host arch and OS!

This should be fixed in Arduino 0012. (Coming out soon, I hope. :) )