Problems with stdio.h

I just received my Arduino Uno today, and after setting up version 1.0.1 for linux64 on my 64 bit (only) Linux system, I attempted to compile the “blinking LED” sketch as documented in Banzi, p. 30.

The following errors occurred:

In file included from /opt/arduino-1.0.1/hardware/arduino/cores/arduino/Print.h:25,
from /opt/arduino-1.0.1/hardware/arduino/cores/arduino/Stream.h:26,
from /opt/arduino-1.0.1/hardware/arduino/cores/arduino/HardwareSerial.h:27,
from /opt/arduino-1.0.1/hardware/arduino/cores/arduino/Arduino.h:193,
from blinking_led.cpp:8:
/usr/include/stdio.h:432: error: expected initializer before ‘throw’
/usr/include/stdio.h:488: error: expected initializer before ‘throw’

The version of gcc installed as reported by the command “gcc --version” is:

gcc (GCC) 4.7.2
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Are there some environment variable overrides I must specify in arduino-1.0.1/arduino which I don’t know about? Somehow the starting script didn’t pick up on the file arduino-1.0.1/hardware/tools/avr/lib/avr/include/stdio.h and use that instead of /usr/include/stdio.h.

The version of avr-gcc might be more useful.

A run of arduino-1.0.1/hardware/tools/avr/bin/avr-gcc --version says it is version GCC version 4.3.2.

It looks to me like you are picking up the wrong stdio.h.

On my Mac, the Arduino one is at:

/Applications/Arduino_1.0.1.app/Contents/Resources/Java/hardware/tools/avr/avr/include/stdio.h

The Arduino is compiled with exceptions disabled, so it shouldn't be seeing "throw" in the library.

I inserted the following two lines in the arduino-1.0.1/arduino script, forcing the compiler to pick up the correct #include files:

CPATH="${APPDIR}/hardware/tools/avr/lib/avr/include"
export CPATH

Put that right before the last line which runs the Java runtime and we will be fine. I think I solved my own problem, and hope to solve someone else's in the future.