Opened 12 years ago

Closed 12 years ago

#5217 closed Bugs (fixed)

File streams broken on Windows with STLPort

Reported by: Andrey Semashev Owned by: Beman Dawes
Milestone: To Be Determined Component: filesystem
Version: Boost 1.46.0 Severity: Showstopper
Keywords: fstream Cc:

Description

In filesystem/v3/fstream.hpp:26 there is an assumption that on Windows STL streams support wide-character file names as arguments. If STLPort is used this is not true. This breaks compilation on this platform with the following output:

C:\_Sources\boost-release\boost/filesystem/v3/fstream.hpp(123) : error C2664: 'stlp_std::basic_ofstream<_CharT,_Traits>::open' : cannot convert parameter 1 from 'const boost::filesystem3::path::value_type *' to 'const char *'
        with
        [
            _CharT=char,
            _Traits=stlp_std::char_traits<char>
        ]
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
        C:\_Sources\boost-release\boost/filesystem/v3/fstream.hpp(123) : while compiling class template member function 'void boost::filesystem3::basic_ofstream<charT>::open(const boost::filesystem3::path &,stlp_std::ios_base::openmode)'
        with
        [
            charT=char
        ]
        libs\log\src\text_file_backend.cpp(1078) : see reference to class template instantiation 'boost::filesystem3::basic_ofstream<charT>' being compiled
        with
        [
            charT=char
        ]
        libs\log\src\text_file_backend.cpp(1440) : see reference to class template instantiation 'boost::log2_mt_nt6::sinks::basic_text_file_backend<CharT>::implementation' being compiled
        with
        [
            CharT=char
        ]

Attachments (1)

fstream.patch (783 bytes ) - added by Andrey Semashev 12 years ago.
The simple patch that fixes the problem

Download all attachments as: .zip

Change History (4)

by Andrey Semashev, 12 years ago

Attachment: fstream.patch added

The simple patch that fixes the problem

comment:1 by Beman Dawes, 12 years ago

Does the following patch work? It is supposed to support all non-Dinkumware libraries.

Thanks,

--Beman

--- c:\temp\fstream_HEAD.hpp 2011-02-23 10:44:34.000000000 -0500 +++ c:\boost\github\libs\filesystem\include\boost\filesystem\v3\fstream.hpp 2011-02-23 10:43:21.000000000 -0500 @@ -24,13 +24,13 @@

#include <boost/config/abi_prefix.hpp> must be the last #include

on Windows, except for standard libaries known to have wchar_t overloads for file stream I/O, use path::string() to get a narrow character c_str() #if defined(BOOST_WINDOWS_API) \

  • && !(defined(_CPPLIB_VER) && _CPPLIB_VER >= 405) not (Dinkumware with overloads)
+ && (!defined(_CPPLIB_VER)
_CPPLIB_VER < 405) (!Dinkumware no wide overloads)

# define BOOST_FILESYSTEM_C_STR string().c_str() use narrow, since wide not available #else use the native c_str, which will be narrow on POSIX, wide on Windows # define BOOST_FILESYSTEM_C_STR c_str() #endif

namespace boost

comment:2 by Beman Dawes, 12 years ago

Never mind. I'm going with your patch.

Thanks,

--Beman

comment:3 by Beman Dawes, 12 years ago

Resolution: fixed
Status: newclosed

Fixed by revision 69220

Note: See TracTickets for help on using tickets.