scoping question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Consider the following code fragment (its kind of long, but makes the point well)

int main(int argc, char** argv)
{
 __label__ END;
 int result = 1;

 int inner()
 {
   __label__ END;
   int result = 1;

   result++;
   goto END;

 END:
   printf("inner result: %d\n", result);
   return result;
 };

 inner();
 goto END;

END:
 printf("result: %d\n", result);
 return result;
}

results from running this program:

inner result: 2
result: 1

So when referencing both variables and labels in the inner scope, that which is defined in the inner scope is what is used.

My question is, is it possible, from within the inner scope, to refer to the variables and labels defined in the outer scope (whose names have been overridden)

I am using GCC 4.3.3

Thank you,
Todd


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux