std::locale problem on Mac OSX

M

meskio

I get a runtime_error while porting a program to Mac OSX 10.6 with
std::locale.

#include <locale>
int main ( int argc, char *argv [] ) {
std::locale mylocale("");
return 0;
}

Returns an error for any locale diferent than "C":
bash-3.2$ LANG=es_ES.UTF-8 ./locale
terminate called after throwing an instance of 'std::runtime_error'
what(): locale::facet::_S_create_c_locale name not valid
Abort trap


Is that a Mac OSX bug? Am I doing something wrong?
 
A

Alf P. Steinbach

I get a runtime_error while porting a program to Mac OSX 10.6 with
std::locale.

#include<locale>
int main ( int argc, char *argv [] ) {
std::locale mylocale("");
return 0;
}

Returns an error for any locale diferent than "C":
bash-3.2$ LANG=es_ES.UTF-8 ./locale
terminate called after throwing an instance of 'std::runtime_error'
what(): locale::facet::_S_create_c_locale name not valid
Abort trap


Is that a Mac OSX bug? Am I doing something wrong?

Sounds like a bug. The C locale and the "" locale (user's default)
should be supported. Anything else you can't count on, but those two
need to be supported if I recall correctly, which I'm pretty sure I do.

Cheers & hth.,

- Alf
 
N

Nobody

Sounds like a bug. The C locale and the "" locale (user's default)
should be supported.

That assumes that the user's default locale is a valid locale. The OS
won't prevent you from setting LANG etc to an invalid locale.

Which locales are valid may vary between individual systems, even for the
same architecture and OS.
 
V

Vaclav Zeman

meskio wrote, On 18.8.2011 0:07:
I get a runtime_error while porting a program to Mac OSX 10.6 with
std::locale.

#include <locale>
int main ( int argc, char *argv [] ) {
std::locale mylocale("");
return 0;
}

Returns an error for any locale diferent than "C":
bash-3.2$ LANG=es_ES.UTF-8 ./locale
terminate called after throwing an instance of 'std::runtime_error'
what(): locale::facet::_S_create_c_locale name not valid
Abort trap
This happens when GCC is not configured with locale support. See
the said:
Is that a Mac OSX bug? Am I doing something wrong?
It might be that MacOS X does not support what GNU libstdc++ needs/wants to
implement fully functional std::locale. I cannot tell as I do not use that OS.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top