Author Topic: Using wchart_t with C::B  (Read 3313 times)

Offline Vanchi

  • Single posting newcomer
  • *
  • Posts: 4
Using wchart_t with C::B
« on: October 05, 2006, 03:57:25 pm »
Hi,

I want to use wchar_t but I cound't succed. I've searched in internet but non of the codes shown there compiled under C::B.

The error is because the compiler sais that wcout is not defined. Whitch library I have to include?

I post one of the codes copied from internet (This is an extrac of the whole code)

Code: [Select]
#include <iostream>
#include <fstream>

using namespace std;

int main( )
{
   int i = 0;
   wcout << L"Enter a number: ";
   wcin >> i;
}



NOTE: I'm using C::B (NB: 13/9/2006)

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Using wchart_t with C::B
« Reply #1 on: October 05, 2006, 04:20:57 pm »
The solution for the particular error that you're getting is trivial, looking at iostream, you see that you have to add: #define _GLIBCXX_USE_WCHAR_T 1

Unluckily, this does not help you a lot, because then you will get unresolved symbols while linking. You will also need a glibc++ that is compiled with this constant (AFAIK there is no such version coming with MinGW).

But... have you tried simply using cout instead? Wide characters are just normal bytes, after all. A few more of them, but still only bytes. If you push a wide string onto cout, it should still get somewhere... or so I guess?
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline Vanchi

  • Single posting newcomer
  • *
  • Posts: 4
Re: Using wchart_t with C::B
« Reply #2 on: October 05, 2006, 07:42:54 pm »
Yes, I tried, but this is the result:

Code: [Select]
[b]code[/b]
...
cout << L"Enter a number: ";
...

[b]output[/b]
0x43e000

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1442
    • CenizaSOFT
Re: Using wchart_t with C::B
« Reply #3 on: October 06, 2006, 12:05:21 am »
I just tried searching for wcout in both gcc 3.4.5 (from MinGW) and gcc 4.1.1 (the one I compiled) and it seems 4.1.1 has wcout and friends available, but I cannot test it right now.

I remember I tried something about Unicode once and it didn't work, I just cannot remember what exactly.

sethjackson

  • Guest
Re: Using wchart_t with C::B
« Reply #4 on: October 06, 2006, 01:43:36 am »
I just tried searching for wcout in both gcc 3.4.5 (from MinGW) and gcc 4.1.1 (the one I compiled) and it seems 4.1.1 has wcout and friends available, but I cannot test it right now.

I remember I tried something about Unicode once and it didn't work, I just cannot remember what exactly.

I've tried wcout and it doesn't work with GCC 3.4.5 (MinGW). I can't remember the errors I got though. Glad to see it seems to be improved in the new version. :)

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1442
    • CenizaSOFT
Re: Using wchart_t with C::B
« Reply #5 on: October 12, 2006, 06:55:53 pm »
I just tried to use wcout with the GCC 4.1.1 I compiled and it works. I you still want to give it a try, just download it from my signature.