Emit a warning if a prototype is not generated due to known limitations #1944
Labels
topic: build-process
Related to the sketch build process
topic: code
Related to content of the project itself
type: enhancement
Proposed improvement
Describe the request
Print a warning when necessary prototype generation for a function was intentionally skipped.
🙂 The user will have useful information about the cause of what would otherwise be a very mysterious compilation error.
Describe the current behavior
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 unless the sketch already contains that prototype.Due to not needing to write them, and due to them not being mentioned anywhere in the official documentation of the Arduino Language, the average Arduino user does not know about function prototypes and takes forward declaration of their functions for granted.
In some cases, it might not be feasible for Arduino CLI to generate a prototype. For example, prototypes are intentionally not generated in the following cases:
Default parameter values
Prototypes are not generated for functions with default parameter values (arduino/Arduino#386):
arduino-cli/legacy/builder/prototypes_adder.go
Lines 86 to 88 in f239754
Compiling a sketch with a function using default parameter values that was referenced before declaration like this:
will fail:
Namespaces
Prototypes are not generated for functions in namespaces (arduino/Arduino#5984):
arduino-cli/legacy/builder/ctags/ctags_parser.go
Lines 167 to 169 in f239754
Compiling a sketch with a function using default parameter values that was referenced before declaration like this:
will fail:
Arduino CLI knows full well that it is omitting an essential prototype, yet doesn't make any effort to communicate that fact to the user.
🙁 The user will have great difficulty in determining the cause of the error and how to fix it. When the user asks for help on the forum, the programming wizards there will take great glee in the opportunity to gripe once again about how terrible of an idea prototype generation is.
Arduino CLI version
f239754
Operating system
All
Operating system version
Any
Additional context
Examples of where this has caused confusion for the users:
Originally suggested at arduino/Arduino#5103 (comment)
Additional Requests
Issue checklist
The text was updated successfully, but these errors were encountered: