[Bug libstdc++/23990] New: compiling code with "wchar_t" .. gives linking error

a_manish at yahoo dot com gcc-bugzilla@gcc.gnu.org
Wed Sep 21 09:31:00 GMT 2005


Hi,
I am facing a problem while compiling following code with gcc.
When i compile ofstream with "char", it compiles fine.
But it gives linking error with "wchar_t".
I compile with command "gcc test.cpp"
Could someone please look into this and let me know if i need additional 
library to compile with ? or what is the exact issue ?
=================================================================
#include <iostream>
#include <istream>
#include <stdio.h>
#include <wchar.h>
#include <stdlib.h>
#include <fstream>
#include <string>
#include <iosfwd>

using namespace std;

int main(void)
{
	//typedef basic_ofstream<char, char_traits<char> > wofstream;
	typedef basic_ofstream<wchar_t, char_traits<wchar_t> > wofstream;
	wofstream wstr;
	wstr.open("test.txt",ios::app);
	char *abc="TEST";
	//str<<abc;
	string t = "TEST1";
	wchar_t *def=0;
	def=(wchar_t*)t.c_str();
	wprintf(L"%s\n",def);
	
	//print to file -start
	wstr<<"\nNEW RUN\n";
	wstr<<(*def);
	wstr<<"\nEND\n";
	//print to file -end

	wstr.close();
	return 0;
}
=================================================================

Thanks in advance.
Manish

-- 
           Summary: compiling code with "wchar_t"    .. gives linking error
           Product: gcc
           Version: 3.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: a_manish at yahoo dot com
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23990



More information about the Gcc-bugs mailing list