Summary: Code that compiles clean on Arduino does not compile with Energia.
The Arduino IDE preprocessor hoists prototypes to the top of the file inserting them after library #include directives.
The Energia IDE preprocessor hoists prototypes to the top of the file but inserts them before the library #include directives. Consequently, any types that the prototypes need from the library #include's are not yet defined, causing compilation errors.
Below is the pertinent captured intermediate preprocessor output from both Arduino and Energia.
== Arduino Preprocessor output - CORRECT - compiles clean ==
== hsmRegion is defined in hsm.h ==
Summary: Code that compiles clean on Arduino does not compile with Energia.
The Arduino IDE preprocessor hoists prototypes to the top of the file inserting them after library #include directives.
The Energia IDE preprocessor hoists prototypes to the top of the file but inserts them before the library #include directives. Consequently, any types that the prototypes need from the library #include's are not yet defined, causing compilation errors.
Below is the pertinent captured intermediate preprocessor output from both Arduino and Energia.
== Arduino Preprocessor output - CORRECT - compiles clean == == hsmRegion is defined in hsm.h ==
line 1 "Blink.ino"
include "hsm.h"
include "Arduino.h"
static bool On_State_Code(void * pObject, hsmRegion * pRegion, const int EventCode); static bool Off_State_Code(void * pObject, hsmRegion * pRegion, const int EventCode); extern void setup(); extern void loop();
line 3
== Energia Preprocessor output - CAUSES COMPILATION ERRORS == == hsmRegion not defined -- prototypes are inserted before #include of hsm.h ==
include "Energia.h"
static bool On_State_Code(void * pObject, hsmRegion * pRegion, const int EventCode); static bool Off_State_Code(void * pObject, hsmRegion * pRegion, const int EventCode); extern void setup(); extern void loop();
line 1
include "hsm.h"