Skip to content

) in comment breaks function prototype generation #1253

Open
@FRautenberg

Description

@FRautenberg

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

a4ee670

Last verified with

c5812ee

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

Metadata

Metadata

Assignees

Labels

priority: lowResolution is a low prioritytopic: build-processRelated to the sketch build processtopic: codeRelated to content of the project itselftype: imperfectionPerceived defect in any part of project

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions