Go Down

Topic: Include file is not parsed (Read 1 time) previous topic - next topic

Jantje

Hi
I noticed that the Arduino IDE does not parse header files when defining the library paths.

I have 2 files. A include.h file and a include.pde file.
The include.h file looks like this:
Code: [Select]
#include <Servo.h>
The include.pde file looks like this:
Code: [Select]
#include "include.h"
Servo Myservo;

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

This does not compile in the arduino IDE

When I change the include.pde to look like this:
Code: [Select]
#include "include.h"
#include <Servo.h>
Servo Myservo;

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

it compiles

Is this considered to be a bug? Could this be fixed?

Best regards
Jantje
Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

frank26080115

Arduino only looks for libraries to compile by using regex to search for #include in your code, if it can't find #include <Servo.h>, then it won't bother actually compiling it, and thus you will get errors about undefined references

see https://github.com/arduino/Arduino/blob/master/app/src/processing/app/preproc/PdePreprocessor.java for details about how this is actually done
Freelance engineer, consultant, contractor. Graduated from UW in 2013.

PaulS

Quote
Arduino only looks for libraries to compile by using regex to search for #include in your code

"code" is a bit too broad. It looks for #include statements in the sketch(es) only. It does not look in header files for other header files.

Paul Stoffregen

I believe this is issue 236.

http://code.google.com/p/arduino/issues/detail?id=236

It's marked as accepted for 1.0, but nobody seems to have actually worked on it (yet).

Jantje

I would be very pleased if this got fixed.
Best regards
jantje
Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

Paul Stoffregen

Maybe this is the perfect opportunity (or motivation) for you to dig into the java code?

Arduino already parses the #include lines from the .pde files, to produce the list of libraries that need to be compiled.  So the "hard work" is already in there.  Code also already exists to build a list of all the .c and .cpp files.

Of all the possible IDE contributions, this one is probably one of the easiest for a beginner to make a significant contribution.

Jantje

Paul
Good point. However I'll pass  8) . There is still plenty of work on my Arduino eclipse plugin
Best regards
Jantje
Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

Go Up