Click here to Skip to main content
15,892,643 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Another academic question - ANSI C standard on optional function parameters Pin
Richard MacCutchan31-Aug-14 20:47
mveRichard MacCutchan31-Aug-14 20:47 
AnswerRe: Another academic question - ANSI C standard on optional function parameters Pin
CPallini1-Sep-14 4:24
mveCPallini1-Sep-14 4:24 
GeneralRe: Another academic question - ANSI C standard on optional function parameters Pin
Vaclav_1-Sep-14 5:33
Vaclav_1-Sep-14 5:33 
GeneralRe: Another academic question - ANSI C standard on optional function parameters Pin
Richard MacCutchan1-Sep-14 6:52
mveRichard MacCutchan1-Sep-14 6:52 
GeneralRe: Another academic question - ANSI C standard on optional function parameters Pin
Vaclav_1-Sep-14 7:55
Vaclav_1-Sep-14 7:55 
GeneralRe: Another academic question - ANSI C standard on optional function parameters Pin
CPallini1-Sep-14 9:39
mveCPallini1-Sep-14 9:39 
GeneralRe: Another academic question - ANSI C standard on optional function parameters Pin
Richard MacCutchan1-Sep-14 21:23
mveRichard MacCutchan1-Sep-14 21:23 
GeneralRe: Another academic question - ANSI C standard on optional function parameters Pin
Vaclav_2-Sep-14 8:11
Vaclav_2-Sep-14 8:11 
OK, I did try this


void TestFunctionA (int a, int b = 100)
{
a += 1;
b += 10;
Serial.print(b);

}

void TestFunctionB (int a)
{
a += 1;
// b += 10;
Serial.print(a);

}


and calls

TestFunctionB (10); // int a, int b = 100)
TestFunctionA(10,234);

And the compiler said too many arguments in function call
But if I change the b to float it compiles and it does makes sense to me. Partially.
If the b parameter b is not passed, than the function A will be executed and compiled.
Confusing, yes.
But that was not the reason I asked. In "real" C compiler when a parameter is declared optional the code will compile without having to change all function calls to include the optional parameter.

But I still do not know if that is ANY standard or just MS compiler specific.

But Arduino compiler expects the "optional" parameter, so it is really not optional.

Cheers Vaclav
GeneralRe: Another academic question - ANSI C standard on optional function parameters Pin
Richard MacCutchan2-Sep-14 20:31
mveRichard MacCutchan2-Sep-14 20:31 
GeneralRe: Another academic question - ANSI C standard on optional function parameters Pin
Vaclav_6-Sep-14 5:59
Vaclav_6-Sep-14 5:59 
GeneralRe: Another academic question - ANSI C standard on optional function parameters Pin
Richard MacCutchan6-Sep-14 6:10
mveRichard MacCutchan6-Sep-14 6:10 
GeneralRe: Another academic question - ANSI C standard on optional function parameters Pin
Stefan_Lang2-Sep-14 21:11
Stefan_Lang2-Sep-14 21:11 
AnswerRe: Another academic question - ANSI C standard on optional function parameters Pin
Stefan_Lang2-Sep-14 0:52
Stefan_Lang2-Sep-14 0:52 
QuestionHow to Resolve the Below Error? Pin
Sunil931-Aug-14 5:37
Sunil931-Aug-14 5:37 
AnswerRe: How to Resolve the Below Error? Pin
«_Superman_»31-Aug-14 6:04
professional«_Superman_»31-Aug-14 6:04 
GeneralRe: How to Resolve the Below Error? Pin
Sunil931-Aug-14 18:23
Sunil931-Aug-14 18:23 
Questionhow to print the value of variable which is define in header file.? Pin
mybm129-Aug-14 21:14
mybm129-Aug-14 21:14 
AnswerRe: how to print the value of variable which is define in header file.? Pin
Richard MacCutchan29-Aug-14 22:57
mveRichard MacCutchan29-Aug-14 22:57 
GeneralRe: how to print the value of variable which is define in header file.? Pin
mybm129-Aug-14 23:06
mybm129-Aug-14 23:06 
GeneralRe: how to print the value of variable which is define in header file.? Pin
Richard MacCutchan29-Aug-14 23:44
mveRichard MacCutchan29-Aug-14 23:44 
GeneralRe: how to print the value of variable which is define in header file.? Pin
mybm129-Aug-14 23:59
mybm129-Aug-14 23:59 
AnswerRe: how to print the value of variable which is define in header file.? Pin
Richard MacCutchan30-Aug-14 0:48
mveRichard MacCutchan30-Aug-14 0:48 
GeneralRe: how to print the value of variable which is define in header file.? Pin
mybm130-Aug-14 19:09
mybm130-Aug-14 19:09 
AnswerRe: how to print the value of variable which is define in header file.? Pin
Stefan_Lang2-Sep-14 2:36
Stefan_Lang2-Sep-14 2:36 
QuestionDisplaying the output of another program Pin
oldbritthumper29-Aug-14 4:49
oldbritthumper29-Aug-14 4:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.