Fix undefined reference errors for StringToVector with GCC and LTO.
This CL addresses link failures when building MuJoCo with GCC and Link Time Optimization (LTO) enabled: - Declared the `StringToVector<std::string>(const std::string&)` specialization in `user_util.h` to prevent the compiler from incorrectly trying to instantiate the general template. - Added an explicit instantiation for `StringToVector<unsigned char>(char*)` in `user_util.cc` to provide the definition needed by its `const std::string&` counterpart. PiperOrigin-RevId: 902557141 Change-Id: I27b585cf1deb276d4150a5cbe6cf7e59c323a20a
This commit is contained in:
committed by
Copybara-Service
parent
eb31027a7c
commit
fa7b36d111
@@ -1346,6 +1346,7 @@ template<> MJAPI std::vector<std::string> StringToVector(const std::string& s) {
|
||||
template MJAPI std::vector<int> StringToVector(char* cs);
|
||||
template MJAPI std::vector<float> StringToVector(char* cs);
|
||||
template MJAPI std::vector<double> StringToVector(char* cs);
|
||||
template MJAPI std::vector<unsigned char> StringToVector(char* cs);
|
||||
|
||||
|
||||
template <typename T> std::vector<T> StringToVector(const std::string& s) {
|
||||
|
||||
@@ -264,6 +264,7 @@ template<typename T> MJAPI std::string VectorToString(const std::vector<T>& v);
|
||||
// convert string to vector
|
||||
template<typename T> MJAPI std::vector<T> StringToVector(char *cs);
|
||||
template<typename T> MJAPI std::vector<T> StringToVector(const std::string& s);
|
||||
template<> MJAPI std::vector<std::string> StringToVector(const std::string& s);
|
||||
|
||||
} // namespace mujoco::user
|
||||
|
||||
|
||||
Reference in New Issue
Block a user