This paper says that setlocale()
is thread unsafe. Is there any thread safe approach to set the locale.
I am coding in C++, but the locale will be used by a function from a C library if it makes any difference.
This is basically what I am doing right now:
const char* loc_old = std::setlocale(ltype, 0);
std::setlocale(ltype, mylocale.c_str()); //change the locale
//call some C functions
std::setlocale(ltype, loc_old); //restore the locale
The solution must be portable and not >=C++11