Skip to content

Regression when using default parameters #23

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

Closed
matthijskooijman opened this issue Sep 30, 2015 · 3 comments
Closed

Regression when using default parameters #23

matthijskooijman opened this issue Sep 30, 2015 · 3 comments
Assignees

Comments

@matthijskooijman
Copy link
Collaborator

Consider this sketch:

void test(int x = 1) {
}

void setup() {
}

void loop() {
}

When using 1.6.5 this compiles, but it breaks when using arduino-builder. I remember reading that supporting optional arguments with arduino-builder/ctags is too tricky, so it was intentionally left out. However, since the old regex-based parser code simply did not recognize functions using default arguments at all (so did not generate a prototype for them), this means that functions using default arguments compiled properly before, but not anymore.

Perhaps it is possible to detect that default arguments are present in a function prototype and if so, refrain from generating a prototype? Ideally, a prototype is generated with the default arguments removed, but that is probably tricky to get right (without involving things like libclang).

@ffissore
Copy link
Contributor

I think I can just look a the signature of the function and if it contains an = sign I can just skip prototype generation. Thank you, I'll work on that asap

@matthijskooijman
Copy link
Collaborator Author

Yeah, I can't think of any prototype that contains an = without using a default argument, so that should work. Perhaps something fancy using C++11 exprtype, but even then preventing a prototype wouldn't really hurt I guess.

@matthijskooijman
Copy link
Collaborator Author

Seems to work, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants