Skip to content

Including FastLED library breaks prototype generation #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
per1234 opened this issue Nov 22, 2017 · 3 comments
Open

Including FastLED library breaks prototype generation #3

per1234 opened this issue Nov 22, 2017 · 3 comments
Labels
help wanted Assistance from the community is especially welcome type: imperfection Perceived defect in any part of project

Comments

@per1234
Copy link
Contributor

per1234 commented Nov 22, 2017

Using Arduino IDE Beta build 25 with Windows 7 64 bit

  • Install FastLED library (it's in the Library Manager index)
  • Compile the following sketch (EDIT: for Arduino/Genuino Uno or other AVR board):
#include <FastLED.h>
void setup() {
  foo();
}
void loop() {}
void foo() {}

Error:

C:\Users\per\AppData\Local\Temp\arduino_modified_sketch_198423\sketch_nov21a.ino: In function 'void setup()':

sketch_nov21a:5: error: 'foo' was not declared in this scope

 void loop() {}

       ^

arduino-preprocessor -debug output:
https://gist.githubusercontent.com/per1234/e2e45e7b84de756ae1782178790c5830/raw/ecdd542f40c951ca8b93f9a585ee72366f6fcfaa/sketch_nov21a.ino.cpp

Examination of the generated .ino.cpp file shows that the foo() prototype was never generated, rather than being inserted in the wrong place.

The issue does not occur in Arduino IDE 1.8.5.

Originally reported at: http://forum.arduino.cc/index.php?topic=512898

@facchinm
Copy link
Member

Hi @per1234 ,
thanks for spotting this; in fact, the libclang backend is failing to analyze a part of the library (it looks like it's the AVR specific macros, incidentally the ones making FastLed magic happen ) and thus it doesn't generate the prototypes.
I can think about a couple of solutions (maybe @cmaglie has some other):

  • fallback on ctags when arduino-preprocessor fails (at least, in the meantime, just to avoid breaking people's sketches)
  • only use user program to generate the prototypes (this should work for prototype generation if no gcc-specific macro is used, but won't provide autocomplete hints)

Anyway, comping on ARM works as expected, so we can use it as a reference. The error thrown (with --output-diagnostic) is

terminate called after throwing an instance of 'std::logic_error'
  what():  basic_string::_S_construct null not valid
Aborted (core dumped)

@facchinm facchinm added bug help wanted Assistance from the community is especially welcome labels Nov 27, 2017
@rsora rsora added type: imperfection Perceived defect in any part of project and removed type: bug labels Sep 16, 2021
@arduino arduino deleted a comment from Subhasish-Behera Nov 20, 2021
@LEKPHET-KUNSUE

This comment was marked as abuse.

@LEKPHET-KUNSUE

This comment was marked as abuse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Assistance from the community is especially welcome type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

4 participants