Hi,
I have some general question about reusing a variable-name. I have some variables which reappear in some functions. Should I give them unique names or is there no problem, even if the functions could be active at the same time:
int funct(int name) {
return 10;
}
int function(int name) {
return funct(name);
}
void loop {
a = function(name);
}
There is only one processor and only one thread so the functions can't be active at the same time.
as a "active" function I meant a "not yet ended" function. This does not have to mean, that they are processed simultanously.
He may be meaning a function being called by another...
right. that is what I mean.
That would be nesting.
okay. I try to ask my question using the correct terms:
Is it completely unproblematic to call a function with a parameter "name" if the function I am calling from has a parameter "name", too? Or might this (in any case) cause some problems)?
KevinT:
Is it completely unproblematic to call a function with a parameter "name" if the function I am calling from has a parameter "name", too? Or might this (in any case) cause some problems)?
There's a couple cases of what you're asking here:
this
void foo(int a) { bar(a); }
void bar(int a) { Serial.print(a); }
foo(1);
and this
void foo(int a) { bar(a); }
void bar(int b) { Serial.print(b); }
foo(1);
will both output this
1
but if you do something like this:
void foo(int a) { int a = 2; bar(a); }
void bar(int b) { Serial.print(b); }
foo(1);