0

i have a
ifstream m_ifsInput
variable and I try to open a file like this:
m_ifsInput.open( sFileName.c_str() );
where sFileName is a std::wstring variable
the error i get when compiling with g++

no matching function for call to ‘std::basic_ifstream<char, std::char_traits<char> >::open(const wchar_t*)’

the thing is the same thing compiles well uner windows. Looking at the error i get with g++ would mean that there is no open method that takes a wchar_t* as parameter, but then, why the heck does it compile with visual studio ??? I mean it's a standard library function.. these should port ...

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by Narue
0

>Looking at the error i get with g++ would mean that there
>is no open method that takes a wchar_t* as parameter
g++ is correct. The C++ standard doesn't define an open member function that takes const wchar_t* as a filename type.

>but then, why the heck does it compile with visual studio ???
Visual Studio is correct. Nothing stops an implementation from supporting extensions to the standard classes as long as the standard stuff is conformant.

>I mean it's a standard library function.. these should port ...
If you rely on extensions, you can't expect your code to be portable.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.