06-12-2010, 02:33 PM
Hello!
Rule 5.2 says that an identifier in a inner scope shall not hide an identifier in an outer scope.
I have two cases where I'm not sure what the rule says.
1. May a function use the name of an identifier that is local for this translation unit, but may be extern global for another translation unit? The first translation unit does not know this identifier at compile-time, so this error should only be detectable at link-time.
2. If the first question was a Yes, does this following code break this rule (it may brake some other Misra rules)?
Rule 5.2 says that an identifier in a inner scope shall not hide an identifier in an outer scope.
I have two cases where I'm not sure what the rule says.
1. May a function use the name of an identifier that is local for this translation unit, but may be extern global for another translation unit? The first translation unit does not know this identifier at compile-time, so this error should only be detectable at link-time.
2. If the first question was a Yes, does this following code break this rule (it may brake some other Misra rules)?
Code:
int func1(void) {
int var = 23;
return var;
}
extern double var; /* The name is reused here, global scope. Probably breaks rule 8.8 */
double func2(void) {
return var;
}
<t></t>