Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boost::Filesystem for Windows requires wchar handling #6

Closed
bugmenot2 opened this issue Apr 9, 2016 · 2 comments
Closed

Boost::Filesystem for Windows requires wchar handling #6

bugmenot2 opened this issue Apr 9, 2016 · 2 comments

Comments

@bugmenot2
Copy link

Hi Felix,

Can you please adjust your Boost implementation to properly support Windows paths?

main.cpp: In function 'int main(int, const char**)':
main.cpp:353:104: error: cannot convert 'const value_type* {aka const wchar_t*}' to 'const char*' for argument '1' to 'void PerFileWrapper(const char*, const ECTOptions&)'
                     for(unsigned i = 0; i < paths.size(); i++){PerFileWrapper(paths[i].c_str(), Options);}
                                                                                                        ^
main.cpp:359:65: error: cannot convert 'const value_type* {aka const wchar_t*}' to 'const char*' for argument '1' to 'void PerFileWrapper(const char*, const ECTOptions&)'
                         PerFileWrapper(paths[i].c_str(), Options);}
                                                                 ^

As defined by Boost:

  class BOOST_FILESYSTEM_DECL path
  {
  public:

    //  value_type is the character type used by the operating system API to
    //  represent paths.

# ifdef BOOST_WINDOWS_API
    typedef wchar_t                        value_type;
    BOOST_STATIC_CONSTEXPR value_type      preferred_separator = L'\\';
# else 
    typedef char                           value_type;
    BOOST_STATIC_CONSTEXPR value_type      preferred_separator = '/';
# endif
    typedef std::basic_string<value_type>  string_type;  
    typedef std::codecvt<wchar_t, char,
                         std::mbstate_t>   codecvt_type;

Boost also defines functions for wchar conversion in the boost::filesystem::path_traits namespace that you can use for this. Thanks!

@fhanau
Copy link
Owner

fhanau commented Apr 11, 2016

Thank you. Is it fixed with ad36d79?

@bugmenot2
Copy link
Author

Yup, it builds now. Thanks for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants