energia / Energia

Fork of Arduino for the Texas Instruments LaunchPad's
http://energia.nu
Other
794 stars 672 forks source link

Energia not honoring #ifdef preprocessor directives when linking libraries #811

Closed axsdenied closed 8 years ago

axsdenied commented 8 years ago

When creating a list of libraries for linking, Energia seems to add all #include statements, without actually checking #ifdef c preprocessor directives.

For example, trying to write one sketch for multiple devices:

define _TIVA

ifdef _TIVA

include "A.h"

else

include "B.h"

endif

will try to link both A and B libraries at the same time and possibly create conflict.

Also mentioned here: http://forum.43oh.com/topic/6284-how-to-select-correct-include-file/

rei-vilo commented 8 years ago

This is a referenced bug from the Processing —aka Arduino— IDE.

Place the critical #ifdef #else #end pre-processing statements on a library.

robertinant commented 8 years ago

This is an Energia/Arduino pre-processor "bug"/"feature" depending how you look at it. The Energia/Arduino IDE parses the Sketch looking for #include's of libraries to collect and add them to the list of files to compile. If you #include libraries that have the same function's, defines, macro's, etc you end up with the linker error you see.

There is currently no way around this other then creating one single library that supports all chips you which to support and use the defines given to you by Energia to make decisions for chip specific functions.

Hope this helps.

axsdenied commented 8 years ago

Not quite, this bug has been fixed in Arduino v1.6.6 but it still exists in Energia. See https://github.com/arduino/Arduino/issues/906 and the fix here: https://github.com/arduino/Arduino/pull/3779

It would be great if we could get the fix as well.

rei-vilo commented 8 years ago

Energia 0101E017 is based on Arduino 1.0.

See ticket Update the IDE to release 1.6.7 of Arduino #588.