[C++]error - templates must have C++ linkage
keywords: C++ linkage
Case:
Compilation Error:
android-ndk-r14b/sources/cxx-stl/gnu-libstdc++/4.9/include\bits/memoryfwd.h(63,3): error: templates must have C++ linkage template<typename>
Solution:
Change extern "C"
to extern "C++"
if used for template of C++.
#ifdef __cplusplus
extern "C++" {
#endif /* __cplusplus */
#include <string>
#include <sstream>
template <typename T>
std::string to_string(T value)
{
std::ostringstream os ;
os << value ;
return os.str() ;
}
#ifdef __cplusplus
}
#endif /* __cplusplus */
你就像黑夜,拥有寂静与群星。——聂鲁达