News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Using wchart_t with C::B

Started by Vanchi, October 05, 2006, 03:57:25 PM

Previous topic - Next topic

Vanchi

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)


#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)

thomas

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."

Vanchi

Yes, I tried, but this is the result:


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

[b]output[/b]
0x43e000

Ceniza

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

Quote from: Ceniza 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.

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. :)

Ceniza

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.