Arduino Compiler Problems

Ostensibly, the Arduino compiler is a c-compiler ... with a few major exceptions !!


Linking unwanted files

The compiler includes files NOT specified with #include statements.

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

At the time that backups were made, the code in the related files was identical, except for the #include statement. (That is the point of backups.) When I tried to test the backups using the compiler included both and, as expected, found duplicate implementations of all the methods.

Looking at the extended messages

it appears that the compiler worked as expected and that the linker pulled in the extra dot-o (object) file that had not been requested.

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.)

There is no excuse for design problems of this nature. Linking in unused object files is beyond sloppy - it is in fact incompetent. And to have your customers complaining about it ... it makes you wonder what else is wrong.

The "solution" (kludgy work around) is simple - place the dot-h and dot-cpp files in a separate "library" directory.

Then the compiler works as expected. A single keywords.txt file in either directory works with both "libraries".


Author: Robert Clemenzi
URL: http:// mc-computing.com / Hardware_Platforms / Arduino / Compiler_Problems.html