digistump / DigistumpArduino

Files to add Digistump support (Digispark, Pro, DigiX) to Arduino 1.6.X (1.6.5+)
932 stars 377 forks source link

At Compile time #127

Closed Palingenesis closed 4 years ago

Palingenesis commented 4 years ago

I have had to move some files not currently using ( .h and .cpp) to a sub folder. I think, If a library/header file is in same folder as .ino file. Compiler reads it even if it has not been #included in the .ino file.

ArminJo commented 4 years ago

which files did you move?

pfeerick commented 4 years ago

This sounds like an Arduino IDE issue, not a issue with the DigistumpArduino BSP. AFAIK, during compilation, the Arduino IDE preprocessor combines all .cpp and .h files in the sketchbook folder together with the main .ino file to effectively make one file. In other words, if it's visible as a tab in the Arduino IDE, it'll be included in the compile, regardless of if you specifically include it or not.

Palingenesis commented 4 years ago

Probably tunnel vision on my part, I am no pro. just a retired hobbyist. The issue is the header in the directory I haven't included in my code, it calls

I take it you should not have files in the same folder as the *.ino file if you are not using them. Even if you don't include them?

I will close this comment. Tim

ArminJo commented 4 years ago

*.h files does not matter. If they are not included, they are not compiled.

Palingenesis commented 4 years ago

As I thought ArminJo, it must be as pfeerick says about the IDE. I have posted the question on the Arduino forum.

My current project I test the code on a NANO and the ATTiny85. So I have: `#ifdef DEVICE_NANO

include

else // DEVICE_ATTINY85

include // https://github.com/puuu/USIWire

endif

` If I have the library for the DS1307 clock (I want to shorten it for the ATTiny85) in the same folder as the .ino file, it wont compile for the ATTiny85, because the DS1307 Library includes the Wire library. Even if I haven't included the DS1307 library in my .ino file.

I learned something new today. (Use a sub-folder for custom libraries with Arduino IDE)

Thank you every one for putting me in the right direction. Tim