public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* wifstream
@ 2014-08-15 15:49 ArbolOne
  2014-08-15 15:54 ` wifstream Jonathan Wakely
  0 siblings, 1 reply; 4+ messages in thread
From: ArbolOne @ 2014-08-15 15:49 UTC (permalink / raw)
  To: gcc >> g++ Mailing List

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

<html>
   <head>

     <meta http-equiv=3D"content-type" content=3D"text/html=3B charset=3Dutf=
-8">
   </head>
   <body bgcolor=3D"#000000" text=3D"#FF6600">
     In my Windows 7 this code doesn't work:<br>
     std::wstring&amp=3B getFileName() {<br>
     =C2=A0=C2=A0=C2=A0 return file_name=3B<br>
     }<br>
     myMethod(){<br>
     wchar_t tmp =3D *getFileName().c_str() =3B<br>
     =C2=A0=C2=A0=C2=A0 std::wifstream infile( tmp )=3B // &lt=3B&lt=3B-- er=
ror: invalid
     conversion from 'wchar_t' to 'const char*' [-fpermissive]<br>
     =C2=A0=C2=A0=C2=A0 return infile.good( )=3B<br>
     }<br>
     <br>
     <br>
     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<br>
     <a class=3D"moz-txt-link-freetext" href=3D"http://msdn.microsoft.com/en=
-us/library/3b5w4311.aspx">http://msdn.microsoft.com/en-us/library/3b5w4311=
.aspx</a><br>
     <br>
     Where did I go wrong? or=2C is this a bug?<br>
     <br>
     g++ : Using built-in specs.<br>
     At line:1 char:1<br>
     + g++ -v 2&gt=3B GCC_version.txt<br>
     + ~~~~~~~~~~~~~~~~~~~~~~~~~<br>
     =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<br>
     =C2=A0=C2=A0=C2=A0 + FullyQualifiedErrorId : NativeCommandError<br>
     =C2=A0<br>
     COLLECT_GCC=3D[DRIVE:]\mingw64\bin\g++.exe<br>
COLLECT_LTO_WRAPPER=3D[DRIVE:]/mingw64/bin/../libexec/gcc/x86_64-w64-mingw3=
2/4.8.2/lto-wrapper.exe<br>
     Target: x86_64-w64-mingw32<br>
     Configured with: ../../../src/gcc-4.8.2/configure
     --host=3Dx86_64-w64-mingw32 --build=3Dx86_64-w64-mingw32 <br>
     --target=3Dx86_64-w64-mingw32 --prefix=3D/mingw64
     --with-sysroot=3D/c/mingw482/x86_64-482-posix-sjlj-rt_v3-rev4/mingw64
     <br>
     --with-gxx-include-dir=3D/mingw64/x86_64-w64-mingw32/include/c++
     --enable-shared --enable-static --enable-targets=3Dall <br>
     --enable-multilib
     --enable-languages=3Dada=2Cc=2Cc++=2Cfortran=2Cobjc=2Cobj-c++=2Clto
     --enable-libstdcxx-time=3Dyes <br>
     --enable-threads=3Dposix --enable-libgomp --enable-libatomic
     --enable-lto --enable-graphite --enable-checking=3Drelease <br>
     --enable-fully-dynamic-string --enable-version-specific-runtime-libs
     --enable-sjlj-exceptions <br>
     --disable-isl-version-check --disable-cloog-version-check
     --disable-libstdcxx-pch --disable-libstdcxx-debug <br>
     --enable-bootstrap --disable-rpath --disable-win32-registry
     --disable-nls --disable-werror --d<br>
     isable-symvers --with-gnu-as --with-gnu-ld --with-arch-32=3Di686
     --with-arch-64=3Dnocona --with-tune-32=3Dgeneric <br>
     --with-tune-64=3Dcore2 --with-libiconv --with-system-zlib
     --with-gmp=3D/c/mingw482/prerequisites/x86_64-w64-mingw32-static <br>
     --with-mpfr=3D/c/mingw482/prerequisites/x86_64-w64-mingw32-static <br>
     --with-mpc=3D/c/mingw482/prerequisites/x86_64-w64-mingw32-static <br>
     --with-isl=3D/c/mingw482/prerequisites/x86_64-w64-mingw32-static <br>
     --with-cloog=3D/c/mingw482/prerequisites/x86_64-w64-mingw32-static
     --enable-cloog-backend=3Disl <br>
     --with-pkgversion=3D'x86_64-posix-sjlj-rev4=2C Built by MinGW-W64
     project' <br>
     --with-bugurl=3D<a class=3D"moz-txt-link-freetext" href=3D"http://sourc=
eforge.net/projects/mingw-w64">http://sourceforge.net/projects/mingw-w64</a=CFLAGS=3D'-O

     -pipe <br>
     -I/c/mingw482/x86_64-482-posix-sjlj-rt_v3-rev4/mingw64/opt/include <br>
     -I/c/mingw482/prerequisites/x86_64-zlib-static/include
     -I/c/mingw482/prerequisites/x86_64-w64-mingw32-static/include' <br>
     CXXFLAGS=3D'-O2 -pipe
     -I/c/mingw482/x86_64-482-posix-sjlj-rt_v3-rev4/mingw64/opt/include <br>
     -I/c/mingw482/prerequisites/x86_64-zlib-static/include
     -I/c/mingw482/prerequisites/x86_64-w64-mingw32-static/include' <br>
     CPPFLAGS=3D LDFLAGS=3D'-pipe
     -L/c/mingw482/x86_64-482-posix-sjlj-rt_v3-rev4/mingw64/opt/lib <br>
     -L/c/mingw482/prerequisites/x86_64-zlib-static/lib
     -L/c/mingw482/prerequisites/x86_64-w64-mingw32-static/lib '<br>
     Thread model: posix<br>
     gcc version 4.8.2 (x86_64-posix-sjlj-rev4=2C Built by MinGW-W64
     project)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: wifstream
  2014-08-15 15:49 wifstream ArbolOne
@ 2014-08-15 15:54 ` Jonathan Wakely
  2014-08-15 19:40   ` wifstream ArbolOne
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Wakely @ 2014-08-15 15:54 UTC (permalink / raw)
  To: ArbolOne; +Cc: gcc >> g++ Mailing List

On 15 August 2014 16:49, ArbolOne wrote:
> 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

That is describing the MS library, it's not the standard.

> Where did I go wrong? or, is this a bug?

No, the standard says that basic_fstream always takes narrow character
strings to specify the filename, even if the stream itself uses wide
characters.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: wifstream
  2014-08-15 15:54 ` wifstream Jonathan Wakely
@ 2014-08-15 19:40   ` ArbolOne
  2014-08-15 20:36     ` wifstream Oleg Endo
  0 siblings, 1 reply; 4+ messages in thread
From: ArbolOne @ 2014-08-15 19:40 UTC (permalink / raw)
  To: gcc-help

I see, VC has it's own way of doing things, thank you for advice. One
more question, where can I have reference to standard library?

On 15/08/2014 11:54 AM, Jonathan Wakely wrote:
> On 15 August 2014 16:49, ArbolOne wrote:
>> 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
> That is describing the MS library, it's not the standard.
>
>> Where did I go wrong? or, is this a bug?
> No, the standard says that basic_fstream always takes narrow character
> strings to specify the filename, even if the stream itself uses wide
> characters.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: wifstream
  2014-08-15 19:40   ` wifstream ArbolOne
@ 2014-08-15 20:36     ` Oleg Endo
  0 siblings, 0 replies; 4+ messages in thread
From: Oleg Endo @ 2014-08-15 20:36 UTC (permalink / raw)
  To: ArbolOne; +Cc: gcc-help

On Fri, 2014-08-15 at 15:40 -0400, ArbolOne wrote:
> I see, VC has it's own way of doing things, thank you for advice. One
> more question, where can I have reference to standard library?

http://en.cppreference.com is usually a good place to start.

> 
> On 15/08/2014 11:54 AM, Jonathan Wakely wrote:
> > On 15 August 2014 16:49, ArbolOne wrote:
> >> 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
> > That is describing the MS library, it's not the standard.
> >
> >> Where did I go wrong? or, is this a bug?
> > No, the standard says that basic_fstream always takes narrow character
> > strings to specify the filename, even if the stream itself uses wide
> > characters.
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-08-15 20:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-15 15:49 wifstream ArbolOne
2014-08-15 15:54 ` wifstream Jonathan Wakely
2014-08-15 19:40   ` wifstream ArbolOne
2014-08-15 20:36     ` wifstream Oleg Endo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).