Re: localetest file cann't compile

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 29 June 2011 19:35, eric wrote:
> ---------------------------------------------------------------
> #include <iostream>
> #include <fstream>
> #include <string>
> //#include <cstring>
>
> using namespace std;
> int main(int argc, char *argv[]) {
>
> /*   try {
>        std::locale::global(std::locale(""));
> } catch ( ... ) { }; */
>
>  wstring ws2 = L"Euro: \x20ac";
>  wofstream out("unicode.txt");
>  if(not out.good())
>   cerr << "Error opening output file" << endl;
>  //const char *name = "el_GR.utf8";
>   const char *name = "en_US.utf8";
>  if(argc == 2)
>   name = argv[1];
>  cout << "trying to access locale " << name << endl;
>  locale loc;
>  try{
>   loc = locale(name);
>   cout << "Generated locale " << loc.name() << endl;
>  }catch( exception &e){
>   cerr << "Couldn't generate locale " << name << ": " << e.what() <<
> endl;
>  }
>  out.imbue(loc);
>  if(not out.good())
>   cerr << "Error when setting the locale" << endl;
>  out << ws2<< endl;
>  if(not out.good())
>   cerr << "Error when writing to file" << endl;
>
> open("unicode.txt", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
> fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 3), ...}) = 0
> mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
> = 0x7fb8588e6000
> write(1, "trying to access locale fr_FR.ut"..., 35trying to access
> locale fr_FR.utf8
> ) = 35
> open("/usr/lib/locale/locale-archive", O_RDONLY) = 4
> fstat(4, {st_mode=S_IFREG|0644, st_size=1527584, ...}) = 0
> mmap(NULL, 1527584, PROT_READ, MAP_PRIVATE, 4, 0) = 0x7fb85875d000
> close(4)                                = 0
> open("/usr/lib/gconv/gconv-modules.cache", O_RDONLY) = 4
> fstat(4, {st_mode=S_IFREG|0644, st_size=26048, ...}) = 0
> mmap(NULL, 26048, PROT_READ, MAP_SHARED, 4, 0) = 0x7fb8588df000
> close(4)                                = 0
> write(1, "Generated locale fr_FR.utf8\n", 28Generated locale fr_FR.utf8
> ) = 28
>
>
> }
>
> ------------------------------------
> root@eric-laptop:/home/eric/cppcookbook# g++ testlocale1.cpp
> testlocale1.cpp:39:49: error: invalid suffix "trying" on integer
> constant

You've copied the program output into your source code, and missed off
the end of the source code.

If you can't manage copy'n'paste then C++ is probably not for you.


> ----------------------------------------------------
> plus, I get an email from someone who work in linux kernel 3.0 about
> this locale issue on g++/ubuntu

The problem is in the locale data files that glibc needs. It's not a
problem with GCC, or the STL.  Th C++ library works correctly (on
Linux, not on Mac OS X) as proven by the fact Axel and I can get the
code to work.  If it doesn't work for you that's because your computer
is not set up correctly.

I've said that several times and have run out of patience now, good luck.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux