arduino / arduino-cli

Arduino command line tool
https://arduino.github.io/arduino-cli/latest/
GNU General Public License v3.0
4.32k stars 373 forks source link

) in comment breaks function prototype generation #1253

Open FRautenberg opened 5 years ago

FRautenberg commented 5 years ago

Describe the problem

In order to make it easier for beginners to get started with writing Arduino sketches, and for the convenience of all users, Arduino CLI automatically generates and adds prototypes for functions defined in a .ino file of a sketch.

🐛 If a closing bracket is commented out within parameters, no prototype is generated for the function.

To reproduce

Compile this sketch:

void setup() {
  foo(1,2);
}
void loop() {}
void foo(int a,  // )
         int b) {}

🐛 Compilation fails spuriously:

C:\Users\per\AppData\Local\Temp\arduino_modified_sketch_281391\sketch_apr03a.ino: In function 'void setup()':
sketch_apr03a:2:3: error: 'foo' was not declared in this scope
   foo(1,2);
   ^~~

Arduino CLI version

Original report

a4ee670a

Last verified with

c5812eea68afdb0e4e774f4f15ec4a34f0c3100c

Operating system

Operating system version

Additional context

If the ) is removed from the comment the prototype generation works correctly:

void setup() {
  foo(1,2);
}
void loop() {}
void foo(int a,  //
         int b) {}

Workaround

Add a prototype for the function in the sketch before the first reference:

void foo(int a, int b);
void setup() {
  foo(1,2);
}
void loop() {}
void foo(int a,  // )
         int b) {}

Issue checklist

per1234 commented 5 years ago

The bug does occur in the hourly build, but not in the beta build of the Arduino IDE, so arduino-preprocessor handles this code correctly.

I'll leave it to the developers to decide whether to consider this bug fixed already.

ubidefeo commented 3 years ago

please @cmaglie see if this is resolved or not

per1234 commented 3 years ago

@ubidefeo it's not resolved. I verified it with the latest nightly Arduino CLI before transferring it here from the arduino/Arduino repository.

ubidefeo commented 3 years ago

@per1234 I have assigned it to @cmaglie based on your previous comment

I'll leave it to the developers to decide whether to consider this bug fixed already.

umbynos commented 1 year ago

This seems to be a problem of the preprocessor (ctags) fixing it upstream is basically impossible, an alternative would be to switch to arduino-prepocessor but needs some love (still uses an old version of llvm). I don't see it coming shortly.