energia / Energia

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

Prototype hoisting not working properly in IDE Preprocessor #229

Closed ghost closed 11 years ago

ghost commented 11 years ago

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"

robertinant commented 11 years ago

Hi @zzglenm Thanks for the report! This has been fixed in the master branch and will be rolled into the next release.

ghost commented 11 years ago

Excellent! Thank you.