zhangjl / google-glog

Automatically exported from code.google.com/p/google-glog
Other
0 stars 0 forks source link

One-definition rule violation #11

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Compile after R51
2. Note that there are many definitions of mutex now.

What is the expected output? What do you see instead?

glog should not violate the ODR (one definition rule).

What version of the product are you using? On what operating system?

Any after r51

Please provide any additional information below.

r51 puts Mutex into an anonymous namespace. It is generally a bad idea to
put anything in headers into anonymous namespaces, because then each
includer gets a unique definition of whatever was in the anonymous
namespace in the includee. Because of C++ mangling, the linker will see
many different copies, each with a different name, that it will not
coalesce (or at least, we should not rely on them being coalesced).

I suggest changing Mutex to be inside namespace glog or namespace
glog_internal.

Original issue reported on code.google.com by mie...@gmail.com on 8 Jul 2009 at 4:49

GoogleCodeExporter commented 9 years ago
r60 should have fixed this. Thanks for the comments!

http://code.google.com/p/google-glog/source/detail?r=60

Original comment by shinichi...@gmail.com on 27 Jul 2009 at 5:46