Linking unwanted files
When I develop, I like to take snapshots of my work as a backup. (Everyone should!) During development, I keep some of the backups in the same directory - but with unique names. I also edited the cpp files to include the corresponding header (dot-h) file. With most languages, this is not a problem. However, the Arduino braindead compiler tries to include all the backups even though only one is specified.
To be specific, the library directory contains
mcHC_SR04.h mcHC_SR04.cpp mcHC_SR04_class.h mcHC_SR04_class.cpp |
#include "mcHC_SR04_class.h" |
mcHC_SR04.cpp mcHC_SR04_class.cpp |
Looking at the extended messages
From the Arduino IDE menu File / Preferences / Show verbose output during compilation |
This problem is discussed on the forum - they have nothing nice to say about the "developers" who put the IDE together! (The following quotes are from 2012 & 2013.)
This is a well documented and well known failing of the Arduino IDE preprocessor.
It's been reported as a problem for years. Like many other problems with the IDE preprocessor, Team Arduino don't think it's a big deal, apparently, so it's not going to be fixed. As it is, it seems to me that the IDE is OK for small applications and novice programmers but not suitable for anyone who ever wants to take the training wheels off. |
The "solution" (kludgy work around) is simple - place the dot-h and dot-cpp files in a separate "library" directory.
C:\downloads\Arduino\arduino-1.0.5-windows\arduino-1.0.5\libraries\HC_SR04 C:\downloads\Arduino\arduino-1.0.5-windows\arduino-1.0.5\libraries\HC_SR04_bk |