mcci-catena / arduino-lmic

LoraWAN-MAC-in-C library, adapted to run under the Arduino environment
https://forum.mcci.io/c/device-software/arduino-lmic/
MIT License
650 stars 212 forks source link

raw-feather example doesn't compile under PlatformIO #265

Closed terrillmoore closed 5 years ago

terrillmoore commented 5 years ago

From #236: A compile error occurs with the raw-feather example and PlatformIO.

/tmp/tmpc7oEhf/src/raw-feather.ino:115:38: error: conflicting declaration of 'void lmic_printf(const char*, ...)' with 'C' linkage
void lmic_printf(const char *fmt, ...);
^
/tmp/tmpc7oEhf/src/raw-feather.ino:104:6: note: previous declaration with 'C++' linkage
// otherwise the linker will complain).
^
*** [.pioenvs/feather32u4/src/raw-feather.ino.cpp.o] Error 1

I'm not sure how to correctly solve this, but commenting the extern "C" it compiles fine.

Unfortunately, this looks like a defect in PlatformIO's scanning of .ino sketches. The extern "C" is intentional. Apparently PlatformIO is lifting the non-extern "C" definition to the synthesized header file that wraps the .ino, and missing the extern "C" part. We may have to omit raw-feather from the list of apps, because this kind of problem is really hard to fix. Or one of us can take the problem to @ivankravets, he's very responsive. (Since this compiles fine with Arduino, and Ivan has his own .ino to .cpp converter, I'm guessing that this is the issues. I've seen this kind of thing before with Visual Micro, which also has it's own .ino parser.)

Another possibility is that the compile flags are subtly different.

Originally posted by @terrillmoore in https://github.com/mcci-catena/arduino-lmic/pull/236#issuecomment-473933692

ivankravets commented 5 years ago

Hi @terrillmoore, thank you so much for the mention! This our bug with INO to CPP preprocessor. I've just fixed it https://github.com/platformio/platformio-core/commit/d9e6111ac3b19721a3c0ee9bb8cc3d5a6add4c44

The final release of PIO Core 3.6.6 is planned for the next week.

You can close this issue.

terrillmoore commented 5 years ago

Thanks, @ivankravets!