-
-
Notifications
You must be signed in to change notification settings - Fork 389
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
No generated prototype for function with multi-line parameters in unsaved sketch #1800
Comments
I went through the steps and found the followings: I did:
Monosnap.screencast.2022-06-02.17-25-30.mp4First off, the LS unexpectedly complains about the missing After the compile request, the IDE2 frontend (FE) correctly detects the dirty state and builds the following source-override map: {
"file:///private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/.arduinoIDE-unsaved202252-19670-84ll7l.icynr/sketch_jun2a/sketch_jun2a.ino": "void setup() {\n foo(1, 2);\n }\n void loop() {}\n void foo(int bar,\n int baz) {}"
} The FE sends the source-override map as part of the compile request to the backend (BE). The BE builds this JSON object for the gRPC request and sends it to the CLI: {
"instance": {
"id": 1
},
"fqbn": "arduino:avr:uno",
"sketchPath": "/private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/.arduinoIDE-unsaved202252-19670-84ll7l.icynr/sketch_jun2a",
"showProperties": false,
"preprocess": false,
"buildCachePath": "",
"buildPath": "",
"buildPropertiesList": [],
"warnings": "none",
"verbose": false,
"quiet": false,
"vidPid": "",
"jobs": 0,
"librariesList": [],
"optimizeForDebug": false,
"exportDir": "",
"clean": false,
"createCompilationDatabaseOnly": false,
"sourceOverrideMap": [
[
"sketch_jun2a.ino",
" void setup() {\n foo(1, 2);\n }\n void loop() {}\n void foo(int bar,\n int baz) {}"
]
],
"libraryList": []
} FE: The FE and BE content difference is odd but must not be crucial. 👆 I will investigate why there are two leading space characters in the BE version of the content, but I doubt this is the root cause of the defect.
Update:
The FE and BE contents are the same for the second attempt. I must have made a mistake while recording the screencast or documenting the step. I leave the original comment untouched, but below is the JSON of the second attempt. {
"instance": {
"id": 1
},
"fqbn": "arduino:avr:uno",
"sketchPath": "/private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/.arduinoIDE-unsaved202252-19670-84ll7l.icynr/sketch_jun2a",
"showProperties": false,
"preprocess": false,
"buildCachePath": "",
"buildPath": "",
"buildPropertiesList": [],
"warnings": "none",
"verbose": false,
"quiet": false,
"vidPid": "",
"jobs": 0,
"librariesList": [],
"optimizeForDebug": false,
"exportDir": "",
"clean": false,
"createCompilationDatabaseOnly": false,
"sourceOverrideMap": [
[
"sketch_jun2a.ino",
"void setup() {\n foo(1, 2);\n}\nvoid loop() {}\nvoid foo(int bar,\n int baz) {}"
]
],
"libraryList": []
} |
Thanks so much for taking the time to investigate this @kittaakos! Using the insight you shared, I am now able to reproduce the issue using Arduino CLI directly, so can verify that this is not anything related to the Arduino IDE code base. I have moved the issue to the appropriate repository. Set up
DemoUse grpcurl to run the following commands:
NotesThe sketch code compiles fine when it is saved to disk:
|
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.An Arduino IDE editor tab can be in one of two states:
Function prototypes are not generated under the following conditions:
🐛 Compilation of the sketch fails spuriously.
To reproduce
🐛 Compilation fails unexpectedly:
(Outdated sketch source in compilation output tracked here:
https://github.com/arduino/arduino-cli/issues/1185
)🐛 Note that the preprocessed sketch program does not contain a function prototype for
void foo(int, int)
:If you compile the identical sketch while it is in a saved state, the function prototype is generated as expected 🙂, so this is not about a fundamental limitation of the prototype generation system of Arduino CLI:
Expected behavior
Prototypes for functions in
.ino
files are always generated.Arduino CLI version
Original report
0.20.2, bundled with Arduino IDE a8ae0bb
Last verified with
0.36.0-rc.1, bundled with Arduino IDE aa9b10d
Operating system
Windows
Operating system version
Additional context
This issue does not occur in Arduino IDE 1.8.16
Originally reported by @UKHeliBob at https://forum.arduino.cc/t/auto-format-using-clang-format-file-produces-code-that-cannot-be-compiled/934610
Related
No such file or directory
" error if line number of#include
directives are changed while editor is "dirty" #2684Workaround
Add a prototype for the function in the sketch before the first reference:
- OR -
Save the sketch before compiling.
Issue checklist
The text was updated successfully, but these errors were encountered: