Author Topic: Duplicate file names  (Read 1474 times)

0 Members and 1 Guest are viewing this topic.


Duplicate file names
« on: January 28, 2012, 05:30:16 PM »

I wanted to compile an existing Arduino project with Wiring because I think some of your stuff is pretty cool and the Arduino development seems to be a little behind...
Anyway, I adapted all "Arduino.h" includes to "Wiring.h" etc and clicked "Verify". It failed.

So why did it fail? I have a file called "Button.h" (and the corresponding "Button.cpp" in my sketch. So my .pde has a line
Code: [Select]
#include "Button.h"The problem is: the IDE matches this line against my file AND the bundled Button library file. Therefore, it tries to link against to different Button.cpp.o files which obviously fails as both of them define different Button classes.

I propose the following change:
Ignore those library files that have the same name as a file in the sketch folder. This change should be backwards compatible.
Another approach would be to only accept
Code: [Select]
#include <...> for library files and interpret
Code: [Select]
#include "..." as local sketch files. I think that would be clean, but could break old code.

In hope of a quick fix,
best regards,


Re: Duplicate file names
« Reply #1 on: January 30, 2012, 05:11:43 AM »
Ok, as I need to compile my project and don't want to change filenames (besides Button.* there is also a Matrix.* which get confused with a built-in library) I recompiled my own version of the Wiring IDE changing processing.app.preproc.PdePreprocessor:109 to
Code: [Select]
String importRegexp = "^\\s*#include\\s+<(\\S+)>";
Hope to get an official fix for this soon, and I'm really looking forward for the IDE independent compilation ;)


Re: Duplicate file names
« Reply #2 on: January 30, 2012, 11:09:37 AM »
hi Kroimon, thanks for submitting the fix, I'll try it tonight : ) Have you run tests afterwards?


Re: Duplicate file names
« Reply #3 on: January 30, 2012, 01:54:47 PM »
Yeah, I tested it and it seems to work.

As I mentioned above, this fix may not be backwards compatible to old sketches that include libraries using the #include "..." syntax with quotes and limits library loading to the #include <...> syntax.

If you choose this fix you have to clearly announce it with the next release so that old sketches can be adapted.

The other way to fix this - only include libraries when there is no equally named file in the current sketch - looks equally easy to implement, but I have no idea where ;-)