Go Down

Topic: IDE include path bug (Read 579 times) previous topic - next topic

dack

There is a serious issue with include paths when using .cpp files. It can be demonstrated as follows:

Create a new sketch using IDE version 1.0.5
Add a new file called "test.cpp"
Paste the following code into test.cpp:
Code: [Select]
#include <SPI.h>
void test(){SPI.begin();}

Attempt to compile. It fails as follows (verbose detail shown):
Code: [Select]
C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -IC:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\variants\standard C:\Users\myuser\AppData\Local\Temp\build5595337925678702317.tmp\foo.cpp -o C:\Users\myuser\AppData\Local\Temp\build5595337925678702317.tmp\foo.cpp.o
foo.cpp:1:17: warning: SPI.h: No such file or directory
foo.cpp: In function 'void test()':
foo.cpp:2: error: 'SPI' was not declared in this scope


The same code compiles fine when pasted into the main file instead of a separate .cpp file. The issue appears to be the generation of the include paths for the g++ command. When using a .cpp file, the include path for SPI.h is not added automatically. Nor can I find any options to manually add it. The result is that libraries can't be used from a .cpp file.

Coding Badly

When using a .cpp file, the include path for SPI.h is not added automatically. Nor can I find any options to manually add it.


Add...

Code: [Select]
#include <SPI.h>

...to top of the sketch (INO or PDE file).

Go Up