It seems I misunderstand how the system works. I tried the following experiment on my iMac:
- modified
Arduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3/kinetis.h by adding the line:
#include "Overrides.h".
- Inserted an empty file called
Overrides.h in my
libraries folder.
- Compiled.
This caused an error, as the file could not be found. It seems that the libraries folder is not in the immediate search path.
Next, I created a fictitious project called OverrideTest and moved the header Overrides.h into it. I modified kinetis.h by replacing the previous #include with the following conditional logic, now using the absolute path:
Code:
#define ABSOLUTE_FULL_PATH "/Users/Andy/Documents/Arduino/OverrideTest/Overrides.h"
#if __has_include ( ABSOLUTE_FULL_PATH )
#include ABSOLUTE_FULL_PATH // Single defined string: This works! //
#endif
This works, whether or not the header file "Overrides.h" exists or not. Yay!
The problems start when I try to assign the absolute address to a #define variable using concatenation. I can concatenate my hardwired project folder with my header file name as follows:
Code:
#define ABSOLUTE_FULL_PATH "/Users/Andy/Documents/Arduino/OverrideTest/Overrides.h" // This is the result we want from concatenation //
[B]#define CONCATEN_PROJ_PATH "/Users/Andy/Documents/Arduino/OverrideTest/"
#define CONCATEN_FILE_NAME "Overrides.h"
#define CONCATEN_FULL_PATH CONCATEN_PROJ_PATH CONCATEN_FILE_NAME[/B]
#if __has_include ( ABSOLUTE_FULL_PATH )
#include ABSOLUTE_FULL_PATH // Absolute single string: This works! //
#endif
[B]#if __has_include ( CONCATEN_FULL_PATH )
#include CONCATEN_FULL_PATH // Concatenated string: DOESN'T WORK => Error! //
#endif[/B]
This throws the error:
Code:
In file included from /Applications/Arduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3/core_pins.h:34:0,
from /Applications/Arduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3/wiring.h:38,
from /Applications/Arduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3/WProgram.h:45,
from /Applications/Arduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3/Arduino.h:6,
from /var/folders/76/fcb9d1nn36s74kz1zlc38kxr0000gn/T/arduino_build_458632/sketch/OverrideTest.ino.cpp:1:
/Applications/Arduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3/kinetis.h:48:40: [B]error: missing ')' after "__has_include__"
#if __has_include ( CONCATEN_FULL_PATH )[/B]
^
/Applications/Arduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3/kinetis.h:48:40: error: missing '(' in expression
Error compiling for board Teensy 3.6.
Printing out the value of the defines (
ABSOLUTE_FULL_PATH and
CONCATEN_FULL_PATH) from the ino file reveals that they have the same value! Strange!
Questions:
1) Should I be able to concatenate #defines this way?
2) Can I fix the value of a define some other way to have it represent the dynamic path to my header file?
3) Can I change the search path to include my project folder, so that I don't have to fiddle with absolute paths?