Skip to content
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

) in comment breaks function prototype generation #1253

Open
3 tasks done
FRautenberg opened this issue Jul 24, 2019 · 5 comments
Open
3 tasks done

) in comment breaks function prototype generation #1253

FRautenberg opened this issue Jul 24, 2019 · 5 comments
Assignees
Labels
priority: low Resolution is a low priority topic: build-process Related to the sketch build process topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@FRautenberg
Copy link

FRautenberg commented Jul 24, 2019

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
@per1234
Copy link
Contributor

per1234 commented Jul 24, 2019

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.

@per1234 per1234 changed the title Commented out ) interfer with function ) in comment breaks function prototype generation Apr 3, 2021
@per1234 per1234 transferred this issue from arduino/Arduino Apr 3, 2021
@ubidefeo
Copy link

ubidefeo commented Apr 7, 2021

please @cmaglie
see if this is resolved or not

@per1234
Copy link
Contributor

per1234 commented Apr 7, 2021

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

@ubidefeo
Copy link

ubidefeo commented Apr 7, 2021

@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.

@fstasi fstasi removed the type: bug label Sep 16, 2021
@rsora rsora added type: imperfection Perceived defect in any part of project topic: core labels Sep 22, 2021
@per1234 per1234 added the topic: code Related to content of the project itself label May 10, 2022
@umbynos
Copy link
Contributor

umbynos commented Oct 12, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: low Resolution is a low priority topic: build-process Related to the sketch build process topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

8 participants