Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 5.2, at what scope is the rule broken?
#1
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)?
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>
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)