std::locale breakage on MacOS 10.6 with LANG=en_US.UTF-8

后端 未结 5 2270
你的背包
你的背包 2020-12-06 01:12

I have a C++ application that I am porting to MacOSX (specifically, 10.6). The app makes heavy use of the C++ standard library and boost. I recently observed some breakage i

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-06 01:38

    I have encountered this problem very recently on Ubuntu 14.04 LTS and on a Raspberry Pi running the latest Raspbian Wheezy.

    It has nothing to do with OS X, rather with a combination of G++ and Boost (at least up to V1.55) and the default locale settings on certain platforms. There are Boost bug tickets sort of related to this issue, see ticket #4688 and ticket #5928.

    My "solution" was first to do some extra locale setup, as suggested by this AskUbuntu posting:

    sudo locale-gen en_US en_US.UTF-8
    sudo dpkg-reconfigure locales
    

    But then, I also had to make sure that the environment variable LC_ALL is set to the value of LANG (it is advisable to put this in your .profile):

    export LC_ALL=$LANG
    

    In my case I use the locale en_US.UTF-8.

    Final remark: the OP said "This program fails when I run this through g++". I understand that this thread was started in 2009, but today there is absolutely no need to use GCC or G++ on the Mac, the much better LLVM/Clang compiler suite is available from Apple free of charge, see the XCode home page.

提交回复
热议问题