From owner-freebsd-questions@FreeBSD.ORG Tue Apr 11 14:31:20 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F272F16A406 for ; Tue, 11 Apr 2006 14:31:20 +0000 (UTC) (envelope-from snnn119@gmail.com) Received: from pproxy.gmail.com (pproxy.gmail.com [64.233.166.179]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3F07E43D7E for ; Tue, 11 Apr 2006 14:31:20 +0000 (GMT) (envelope-from snnn119@gmail.com) Received: by pproxy.gmail.com with SMTP id t32so1356863pyc for ; Tue, 11 Apr 2006 07:31:19 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:disposition-notification-to:date:from:reply-to:organization:user-agent:x-accept-language:mime-version:to:subject:content-type:content-transfer-encoding; b=OnLIJofodFpuxTykENLdDksSGEu5KV73OznsdB4tkMZJ4lANyDqnsI//Z6XGOQjQCsRSFJzhvfJSEDcqa3XOHoz7HaKZoqAuQtWMKTco6RmVYgfpDGOTguKk7JjuNFLrVKNy/79MJWpNunCnr2ETyszWXKBWY7d1lL9IZbDRtfY= Received: by 10.35.121.2 with SMTP id y2mr1205728pym; Tue, 11 Apr 2006 07:31:19 -0700 (PDT) Received: from ?222.187.44.15? ( [222.187.44.15]) by mx.gmail.com with ESMTP id i70sm10847pye.2006.04.11.07.31.18; Tue, 11 Apr 2006 07:31:19 -0700 (PDT) Message-ID: <443B968A.2020209@gmail.com> Date: Tue, 11 Apr 2006 19:44:10 +0800 From: snnn Organization: snnn User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051210) X-Accept-Language: en-us, en, zh-cn, zh-tw, zh, fr-fr, fr MIME-Version: 1.0 To: freebsd-questions@freebsd.org Content-Type: text/plain; charset=GB18030; format=flowed Content-Transfer-Encoding: 7bit Subject: I can't use any locale except "C" under c++ X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: snnn119@gmail.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Apr 2006 14:31:21 -0000 I think that's because FreeBSD is building gcc with --enable-clocale=generic and the generic code for _S_create_c_locale is as such: void locale::facet::_S_create_c_locale(__c_locale& __cloc, const char* __s, __c_locale) { // Currently, the generic model only supports the "C" locale. // See http://gcc.gnu.org/ml/libstdc++/2003-02/msg00345.html __cloc = NULL; if (strcmp(__s, "C")) __throw_runtime_error(__N("locale::facet::_S_create_c_locale " "name not valid")); } So even if the simplest (e.g. the following one) code will always catch a failure. try{ std::locale::global(std::locale("")); } catch(std::runtime_error ex){ //fail... std::locale::global(std::locale("C")); } Indeed,std::locale("") will return the default locale setting of native environment(similar as setlocale("") ),but now it may always throw an error of "name not valid".It's badly. what should I do? install another gcc from ports?