Skip to content

Function prototypes not generated when sketch path contains " #1945

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
3 tasks done
per1234 opened this issue Oct 25, 2022 · 2 comments
Open
3 tasks done

Function prototypes not generated when sketch path contains " #1945

per1234 opened this issue Oct 25, 2022 · 2 comments
Assignees
Labels
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

@per1234
Copy link
Contributor

per1234 commented Oct 25, 2022

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 the parent path of a sketch contains a double quote character ("), function prototypes are not generated.

To reproduce

$ arduino-cli version
arduino-cli  Version: nightly-20221024 Commit: 5efa9b5 Date: 2022-10-24T01:36:36Z

$ mkdir --parents /tmp/foo\"bar/SomeSketch

$ printf "void setup() {\n  foo();\n}\nvoid loop() {}\nvoid foo() {}" > /tmp/foo\"bar/SomeSketch/SomeSketch.ino

$ arduino-cli compile --fqbn arduino:avr:uno --preprocess /tmp/foo\"bar/SomeSketch
#line 1 "/tmp/foo\"bar/SomeSketch/SomeSketch.ino"
void setup() {
  foo();
}
void loop() {}
void foo() {}


Used platform Version Path                                                    
arduino:avr   1.8.5   /home/per/.arduino15/packages/arduino/hardware/avr/1.8.5

$ arduino-cli compile --fqbn arduino:avr:uno /tmp/foo\"bar/SomeSketch
/tmp/foo"bar/SomeSketch/SomeSketch.ino: In function 'void setup()':
/tmp/foo"bar/SomeSketch/SomeSketch.ino:2:3: error: 'foo' was not declared in this scope
   foo();
   ^~~

🐛 The function prototype for foo was not generated. It will be very difficult for the average user to understand why the compilation failed and how to fix the error.

Expected behavior

Function prototypes are generated regardless of which characters are present in the path.

Arduino CLI version

f239754

Operating system

Ubuntu, macOS

Operating system version

  • Ubuntu 20.04
  • macOS 12.6

Additional context

The bug is not applicable to Windows because " is not an allowed character for Windows paths.


Note this is not about supporting double quotes in sketch filenames. This is about their presence in the parent path of the sketch.


Originally reported at https://forum.arduino.cc/t/mac-montery-and-library-update/1041060/21

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 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels Oct 25, 2022
@cmaglie cmaglie added the topic: build-process Related to the sketch build process label Apr 28, 2023
@cmaglie
Copy link
Member

cmaglie commented May 11, 2023

The problem is that the ctags version we are using is not able to parse the #line directive correctly.
Here is a patch to ctags arduino/ctags#18 but I'm wondering if it's time to move to a more modern version of ctags.

/cc @umbynos @facchinm

@umbynos
Copy link
Contributor

umbynos commented May 23, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

3 participants