User forums > General (but related to Code::Blocks)
Using wchart_t with C::B
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)
--- Code: ---#include <iostream>
#include <fstream>
using namespace std;
int main( )
{
int i = 0;
wcout << L"Enter a number: ";
wcin >> i;
}
--- End code ---
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?
Vanchi:
Yes, I tried, but this is the result:
--- Code: ---[b]code[/b]
...
cout << L"Enter a number: ";
...
[b]output[/b]
0x43e000
--- End code ---
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.
--- End quote ---
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. :)
Navigation
[0] Message Index
[#] Next page
Go to full version