Search code examples
c++thread-safetylocaleprintf

How to get equivalent of printf_l on Linux?


This function exists on OS X and allows you to pass custom local to the function. setlocale is not thread-safe, and passing locale as parameter is.

If there is no equivalent, any way of locale-independent printf, or printf just for doubles (%g) will be ok.


Solution

  • There are locale-independent double to string convertion routines at http://www.netlib.org/fp/. String to double conversion is available too. The API is not very nice, but the code works.