arduino / arduino-builder

A command line tool for compiling Arduino sketches
GNU General Public License v2.0
457 stars 114 forks source link

Another Preprocessor error #28

Closed NicoHood closed 8 years ago

NicoHood commented 8 years ago
void setup() {}

void loop() {
  // Visualize leds via Adalight
  int8_t newData = adalight();

}

//#define ADALIGHT_USE_TEMPLATE

#ifdef ADALIGHT_USE_TEMPLATE
#error
int16_t adalight_template()
#else
int8_t adalight()
#endif
{
  // Flag if the leds got a new frame that should be updated
  return 0;
}

/*
 * sketch_oct03d:5: error: 'adalight' was not declared in this scope
   int8_t newData = adalight();
 */

Error in code above, should be self explaining.

NicoHood commented 8 years ago

Another example this the same error. Might be two separat issues, I dont know whats behind the code. So I post it here, pretending its the same reason which causes this:

void setup() {}
void loop() {
  int8_t newData = adalight();
}

//#define ADALIGHT_USE_TEMPLATE

#ifdef ADALIGHT_USE_TEMPLATE
#error
#else
// commenting this header makes the sketch compile
int8_t adalight();
#endif
int8_t adalight()
{
  return 0;
}
ffissore commented 8 years ago

In your second sketch, int8_t adalight(); is a prototype and you must specify it at the beginning of the sketch

ffissore commented 8 years ago

Your first sketch still doesn't compile, unless you rename int16_t adalight_template() to int16_t adalight(). CTags gets fooled by define and it's not even seeing int8_t adalight()

ffissore commented 8 years ago

More info at http://linux.die.net/man/1/ctags, scroll down to "Operational Details"

NicoHood commented 8 years ago

So this is intended?

ffissore commented 8 years ago

No, it's a known limitation of ctags. We have to either fix it or get used to it. Maybe this one will help us