-
-
Notifications
You must be signed in to change notification settings - Fork 403
Generated function prototype injected before declaration of custom parameter type #1269
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
Comments
Hi @allnick. Thanks for your report. During sketch preprocessing, the Arduino build system (which is implemented here in the Arduino CLI code base) automatically generates function prototypes in .ino files for any functions that don't already have a prototype. This turns out to be surprisingly difficult. Although the prototype generation system works fine for most sketches, under certain circumstances, it inserts the prototype at the wrong position in the code. That is the cause of the error you encountered. You can see how the code looks after preprocessing here:
Note that the The workaround is to simply manually add your own prototype in the correct location: void none(){}
struct tword{
byte low;
byte high;
};
bool test(tword par); // function prototype
bool test(tword par){return true;}
void setup() {
word w;
tword* var = (tword*)(&w);
}
void loop(){} |
Respected per1234. Thanks for your explanation. |
The type declared after any function is not visible as the parameter type for any other function below.
Although it is suitable for other purposes.
For example:
It's ok.
Too it's ok
Compilation fails with the error:
Additional context
Additional reports
The text was updated successfully, but these errors were encountered: