-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Prototypes for methods with default arguments are not generated [imported] #386
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
Please checkout this thread [1] on devs mailing list and try one of the linked IDEs. It should fix the problems reported in this issue |
With #3779 the preprocessed code is now
which now fails with
Can you help spot the error? Code looks good to me |
The default argument must be defined only once per compilation unit, for example you can't write: void test(int a=0);
void test(int a=0) { /* empty */ } even if the default argument void test(int a);
void test(int a=0) { /* empty */ } and void test(int a=0);
void test(int a) { /* empty */ } and both compiles fine. |
Now I remember an old chat about it. I chose not to handle default args. Reason is that the correct way of using default args is to have the prototype list them, as in @cmaglie second example void test(int a=0);
void test(int a) { /* empty */ } However this implies that preprocessor must change original source code: I mean not just inserting code, but changing existing code. This is dangerous as we don't have a source code manipulation tool powerful enough to handle all the possible cases (eg: functions defined on multiple lines, spaces, comments between arguments on multi lines...) So this is a wontfix. If you want to use default arguments, you have to define the prototype yourself. #3779 is now smart enough to understand that a function with default args already has its prototype and leave it alone |
Add before() for initialisations before radio hogs SPI
This is Issue 386 moved from a Google Code project.
Added by 2010-10-23T13:23:50.000Z by [email protected].
Please review that bug for more context and additional comments, but update this bug.
Original labels: Type-Defect, Priority-Medium, Component-PreProcessor
Original description
Steps to reproduce the issue:
STEP 1. Insert the following code into a blank sketch:
STEP 2: Click the verify button and observe the error message:
STEP 3:
Examine the generated *.cpp file and observe that a prototype has been generated for test1 but not test2:
What is the expected output? What do you see instead?
You would expect a prototype to be generated for test2.
What version of the Arduino software are you using? On what operating
system? Which Arduino board are you using?
Tested in 0018 and 0021. Running on Win7 Home Premium (though the issue likely exists on all platforms)
Please provide any additional information below.
Of course the workaround is relatively simple (just define the prototype yourself) but it would be nice for all methods to be treated equally.
The text was updated successfully, but these errors were encountered: