Re: typedef name question

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

 



Hi Michal,

John (Eljay) Love-Jensen wrote:
> You are allowed to introduce identifiers in a scope that
> shadow identifiers outside that scope.  Even in the
> "foo foo;" case, where you are using an outer scope
> identifier and in the process are introducing a new
> identifier that shadows that self-same outer
> scope identifier.

Just a small add-on:

In C++ you can easily test this rule and still access the outer identifier by explicitly looking it up in global namespace scope. The following compiles with g++:

// foo is defined in the global namespace
typedef int foo;

foo foo_fct(int a) {
   foo foo;              /* line 3: a variable foo with type foo */
   return (::foo)foo;    /* line 4: cast to outer foo */
}


Of course, this does not work with C.

Daniel

[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