Prototype not generated for function with inline attribute #2697
Labels
topic: build-process
Related to the sketch build process
type: imperfection
Perceived defect in any part of project
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.Attributes can be used to specify properties of a function. The attribute declaration may be placed at a variety of locations relative to a function definition.
🐛 A prototype is not generated for the function if the attribute declaration is placed between the type and name in the function definition.
To reproduce
Setup environment
Demo
🐛 The compilation failed unexpectedly.
By looking at the C++ code generated by the Arduino sketch preprocessor, we can see the cause of the error:
🐛 The compilation failure was caused by Arduino CLI not creating a prototype for the
foo
function.Expected behavior
Prototypes are generated for functions with attribute declarations between the type and name.
Arduino CLI version
c5812ee
Operating system
Operating system version
Additional context
Originally reported by @JLBCS at https://forum.arduino.cc/t/iram-attr-questions/1297715
In the real world sketch shared there,
IRAM_ATTR
was used. This is a macro for an__attribute__
declaration, provided by Espressif's esp-idf framework.Additional reports
Related
extern "C"
when comment contains//
#1591extern "C"
when usingextern "C" { ... }
to mix C functions in an.ino
file. #1618Workaround
Manually add a function prototype to the sketch:
Issue checklist
The text was updated successfully, but these errors were encountered: