You're allowed to have a bunch of variables with the same name, as long as they have different scope; but you can only see one of them at a time (whichever one is "closest", i.e. has the smallest scope). So the following is perfectly fine:
Code:
int a; //1
int someFunction(void);
int main(void) {
int a; //2
if (scanf("%d", &a)) {
int a = 4; //3
printf("a=%d\n", a);
}
printf("a also = %d\n", a);
someFunction();
return 0;
}
int someFunction(void) {
printf("a is %d\n", a);
{
int a = 11; //4
printf("a is also %d\n", a);
}
return a;
}
Each of the variables here has a scope: 1 is in scope for the entire file (and therefore since it has the "largest" scope, it is hidden by any of the other variables named a); 2 is in scope inside main; 3 is in scope inside the if statement; and 4 is in scope only inside those braces in someFunction. You should be able to see then that each printf statement references a different variable "a".
This is relevant because the line you posted:
Code:
int Text_Size = shdr.sh_size;
declares a new variable that is only valid inside that if-statement, and doesn't affect any other variable that may have the name Text_Size somewhere else.
Having said that: I doubt there's a reason why the "normal" returning-a-value-from-a-function mechanism (namely, "return", or if you want an error-code return, passing a pointer to a variable to be filled in by your function) shouldn't be used instead.