[Top][All Lists]

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

Re: two instances of global from shared lib linked with -Bsymbolic

From: Rafal Dabrowa
Subject: Re: two instances of global from shared lib linked with -Bsymbolic
Date: Thu, 8 Apr 2004 10:09:56 +0200
User-agent: KMail/1.6.1

On Wednesday 07 of April 2004 15:47, Ian Lance Taylor wrote:
> I personally think that the ELF
> behaviour is simpler to understand: if the main program and a shared
> library use the same name for a global variable, then they refer to
> the same global variable.

I don't think so. Compare with C/C++ rules:
        - if a function defines variable with the same name as a global 
          the local variable is used when refer to variable name.
        - if a class has defined variable/function with the same name/prototype 
          the global one, the class member is used by default when another 
          function uses it.
        - similar - namespaces.
A shared library is like a namespace. When you write in C++:
        namespace A {
                void f() { ... }
                void g() { f(); }
        namespace B {
                using namespace A;
                void f() { ... }
                void h() { g(); }
Thinking in the same way, as you think about shared libraries. "because 
namespace B uses namespace A (like link of shared library), then B::f 
overrides A::f in B, thus, function A::g invoked from B::h uses B::f". 
Right ? Do you think that this would be easier to understand ?
Did you never thought, that function/variable names may simply clash ?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]