Open
Description
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
Last verified with
Operating system
- Windows
Operating system version
- Windows 10
- Windows 11
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
- I searched for previous reports in the issue tracker
- I verified the problem still occurs when using the nightly build
- My report contains all necessary details