Pages: [1]   Go Down
Author Topic: IDE include path bug  (Read 563 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#include <SPI.h>
void test(){SPI.begin();}
Attempt to compile. It fails as follows (verbose detail shown):
Code:
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.
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 212
Posts: 13085
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#include <SPI.h>

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

Pages: [1]   Go Up
Jump to: