Let's say I have library (A)
implementing the singleton pattern (it has a static variable in its implementation).
(A)
library is compiled as a static library.
Now, let's say I have in my probject:
(B)
, another static library linking statically with(A)
.(C)
, another static library linking statically with(A)
.(D)
, a top level program linking with(B)
and(C)
.
In the end, is my singleton really a singleton (and my variable really static)? Are (B)
and (C)
seing the same static variable from (A)
(is it unic)? Or does the fact that (A)
was statically linked twice embedded (A)
's code twice ending up with my static variable from (A)
appearing twice in the final binary code? Then if (B)
modifies the static variable value, (C)
would not see the change?
Note: I experienced that when changing the libraries of project to be linked statically instead of dynamically. I'm just wondering if I did something wrong, or if that's a normal known behaviour.