From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 510 invoked by alias); 15 Aug 2014 15:49:24 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 500 invoked by uid 89); 15 Aug 2014 15:49:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.6 required=5.0 tests=AWL,BAYES_20,FREEMAIL_FROM,MSGID_FROM_MTA_HEADER,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 X-HELO: BLU004-OMC4S3.hotmail.com Received: from blu004-omc4s3.hotmail.com (HELO BLU004-OMC4S3.hotmail.com) (65.55.111.142) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA256 encrypted) ESMTPS; Fri, 15 Aug 2014 15:49:21 +0000 Received: from BLU436-SMTP84 ([65.55.111.135]) by BLU004-OMC4S3.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.22712); Fri, 15 Aug 2014 08:49:19 -0700 X-TMN: [uWA/1fhiwP+Y+GIem7X2t8CLGrfqlAtN] Message-ID: Received: from [192.168.33.111] ([24.246.37.44]) by BLU436-SMTP84.smtp.hotmail.com over TLS secured channel with Microsoft SMTPSVC(8.0.9200.16384); Fri, 15 Aug 2014 08:49:18 -0700 Date: Fri, 15 Aug 2014 15:49:00 -0000 From: ArbolOne User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-Version: 1.0 To: "gcc >> g++ Mailing List" Subject: wifstream Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2014-08/txt/msg00109.txt.bz2 In my Windows 7 this code doesn't work: std::wstring& getFileName() { return file_name; } myMethod(){ wchar_t tmp = *getFileName().c_str() ; std::wifstream infile( tmp ); // <<-- error: invalid conversion from 'wchar_t' to 'const char*' [-fpermissive] return infile.good( ); } It seems to me that std::wifstream does not accept wchar_t as a value type, but only const char*, contrary to to what is explained in http://msdn.microsoft.com/en-us/library/3b5w4311.aspx Where did I go wrong? or, is this a bug? g++ : Using built-in specs. At line:1 char:1 + g++ -v 2> GCC_version.txt + ~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (Using built-in specs.:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError COLLECT_GCC=[DRIVE:]\mingw64\bin\g++.exe COLLECT_LTO_WRAPPER=[DRIVE:]/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/4.8.2/lto-wrapper.exe Target: x86_64-w64-mingw32 Configured with: ../../../src/gcc-4.8.2/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/c/mingw482/x86_64-482-posix-sjlj-rt_v3-rev4/mingw64 --with-gxx-include-dir=/mingw64/x86_64-w64-mingw32/include/c++ --enable-shared --enable-static --enable-targets=all --enable-multilib --enable-languages=ada,c,c++,fortran,objc,obj-c++,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --enable-sjlj-exceptions --disable-isl-version-check --disable-cloog-version-check --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --d isable-symvers --with-gnu-as --with-gnu-ld --with-arch-32=i686 --with-arch-64=nocona --with-tune-32=generic --with-tune-64=core2 --with-libiconv --with-system-zlib --with-gmp=/c/mingw482/prerequisites/x86_64-w64-mingw32-static --with-mpfr=/c/mingw482/prerequisites/x86_64-w64-mingw32-static --with-mpc=/c/mingw482/prerequisites/x86_64-w64-mingw32-static --with-isl=/c/mingw482/prerequisites/x86_64-w64-mingw32-static --with-cloog=/c/mingw482/prerequisites/x86_64-w64-mingw32-static --enable-cloog-backend=isl --with-pkgversion='x86_64-posix-sjlj-rev4, Built by MinGW-W64 project' --with-bugurl=http://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -I/c/mingw482/x86_64-482-posix-sjlj-rt_v3-rev4/mingw64/opt/include -I/c/mingw482/prerequisites/x86_64-zlib-static/include -I/c/mingw482/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -I/c/mingw482/x86_64-482-posix-sjlj-rt_v3-rev4/mingw64/opt/include -I/c/mingw482/prerequisites/x86_64-zlib-static/include -I/c/mingw482/prerequisites/x86_64-w64-mingw32-static/include' CPPFLAGS= LDFLAGS='-pipe -L/c/mingw482/x86_64-482-posix-sjlj-rt_v3-rev4/mingw64/opt/lib -L/c/mingw482/prerequisites/x86_64-zlib-static/lib -L/c/mingw482/prerequisites/x86_64-w64-mingw32-static/lib ' Thread model: posix gcc version 4.8.2 (x86_64-posix-sjlj-rev4, Built by MinGW-W64 project) --------------080705040301000406020404 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable In my Windows 7 this code doesn't work:
std::wstring&=3B getFileName() {
=C2=A0=C2=A0=C2=A0 return file_name=3B
}
myMethod(){
wchar_t tmp =3D *getFileName().c_str() =3B
=C2=A0=C2=A0=C2=A0 std::wifstream infile( tmp )=3B // <=3B<=3B-- er= ror: invalid conversion from 'wchar_t' to 'const char*' [-fpermissive]
=C2=A0=C2=A0=C2=A0 return infile.good( )=3B
}


It seems to me that=C2=A0 std::wifstream does not accept wchar_t as a value type=2C but only const char*=2C contrary to to what is explained in
http://msdn.microsoft.com/en-us/library/3b5w4311= .aspx

Where did I go wrong? or=2C is this a bug?

g++ : Using built-in specs.
At line:1 char:1
+ g++ -v 2>=3B GCC_version.txt
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
=C2=A0=C2=A0=C2=A0 + CategoryInfo=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 : NotSpecified: (Using built-in specs.:String) []=2C RemoteException
=C2=A0=C2=A0=C2=A0 + FullyQualifiedErrorId : NativeCommandError
=C2=A0
COLLECT_GCC=3D[DRIVE:]\mingw64\bin\g++.exe
COLLECT_LTO_WRAPPER=3D[DRIVE:]/mingw64/bin/../libexec/gcc/x86_64-w64-mingw3= 2/4.8.2/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-4.8.2/configure --host=3Dx86_64-w64-mingw32 --build=3Dx86_64-w64-mingw32
--target=3Dx86_64-w64-mingw32 --prefix=3D/mingw64 --with-sysroot=3D/c/mingw482/x86_64-482-posix-sjlj-rt_v3-rev4/mingw64
--with-gxx-include-dir=3D/mingw64/x86_64-w64-mingw32/include/c++ --enable-shared --enable-static --enable-targets=3Dall
--enable-multilib --enable-languages=3Dada=2Cc=2Cc++=2Cfortran=2Cobjc=2Cobj-c++=2Clto --enable-libstdcxx-time=3Dyes
--enable-threads=3Dposix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=3Drelease
--enable-fully-dynamic-string --enable-version-specific-runtime-libs --enable-sjlj-exceptions
--disable-isl-version-check --disable-cloog-version-check --disable-libstdcxx-pch --disable-libstdcxx-debug
--enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --d
isable-symvers --with-gnu-as --with-gnu-ld --with-arch-32=3Di686 --with-arch-64=3Dnocona --with-tune-32=3Dgeneric
--with-tune-64=3Dcore2 --with-libiconv --with-system-zlib --with-gmp=3D/c/mingw482/prerequisites/x86_64-w64-mingw32-static
--with-mpfr=3D/c/mingw482/prerequisites/x86_64-w64-mingw32-static
--with-mpc=3D/c/mingw482/prerequisites/x86_64-w64-mingw32-static
--with-isl=3D/c/mingw482/prerequisites/x86_64-w64-mingw32-static
--with-cloog=3D/c/mingw482/prerequisites/x86_64-w64-mingw32-static --enable-cloog-backend=3Disl
--with-pkgversion=3D'x86_64-posix-sjlj-rev4=2C Built by MinGW-W64 project'
--with-bugurl=3Dhttp://sourceforge.net/projects/mingw-w64 -I/c/mingw482/x86_64-482-posix-sjlj-rt_v3-rev4/mingw64/opt/include
-I/c/mingw482/prerequisites/x86_64-zlib-static/include -I/c/mingw482/prerequisites/x86_64-w64-mingw32-static/include'
CXXFLAGS=3D'-O2 -pipe -I/c/mingw482/x86_64-482-posix-sjlj-rt_v3-rev4/mingw64/opt/include
-I/c/mingw482/prerequisites/x86_64-zlib-static/include -I/c/mingw482/prerequisites/x86_64-w64-mingw32-static/include'
CPPFLAGS=3D LDFLAGS=3D'-pipe -L/c/mingw482/x86_64-482-posix-sjlj-rt_v3-rev4/mingw64/opt/lib
-L/c/mingw482/prerequisites/x86_64-zlib-static/lib -L/c/mingw482/prerequisites/x86_64-w64-mingw32-static/lib '
Thread model: posix
gcc version 4.8.2 (x86_64-posix-sjlj-rev4=2C Built by MinGW-W64 project)