Modify

Opened 6 years ago

Closed 6 years ago

#5217 closed Bugs (fixed)

File streams broken on Windows with STLPort

Reported by: andysem Owned by: bemandawes
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 andysem 6 years ago.
The simple patch that fixes the problem

Download all attachments as: .zip

Change History (4)

Changed 6 years ago by andysem

The simple patch that fixes the problem

comment:1 Changed 6 years ago by bemandawes

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 Changed 6 years ago by bemandawes

Never mind. I'm going with your patch.

Thanks,

--Beman

comment:3 Changed 6 years ago by bemandawes

  • Resolution set to fixed
  • Status changed from new to closed

Fixed by revision 69220

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain bemandawes.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.