adonis0147 opened a new pull request, #1936:
URL: https://github.com/apache/incubator-brpc/pull/1936

   Recently, I met some linkage errors while using `LLD` linker to compile the 
source code of Apache Doris. The issue looks like #1809 .
   
   ** src/butil/class_name.h **
   ```cpp
   namespace detail {
   template <typename T> struct ClassNameHelper { static std::string name; };
   template <typename T> std::string ClassNameHelper<T>::name = 
demangle(typeid(T).name());
   }
   ```
   
   The linkage of ```ClassNameHelper<T>::name``` here is external due to it is 
variable template and it may cause the duplicate symbols error.
   
   Some ways to fix it:
   1. In C++ 17, use `inline variable`.
   2. Before C++ 17, use unnamed namespace to make the linkage of 
```ClassNameHelper<T>::name``` internal.
   
   In this PR, I suggest using the second way to fix it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to