Skip to content

Compilation fails on Windows when building with UNICODE #146

@saraedum

Description

@saraedum

Compiling cppast fails on Windows with:

%SRC_DIR%\src\libclang\libclang_parser.cpp(250): error C2664: 'TinyProcessLib::Process::Process(const std::vector<TinyProcessLib::Process::string_type,std::allocator<TinyProcessLib::Process::string_type>> &,const TinyProcessLib::Process::string_type &,std::function<void (const char *,size_t)>,std::function<void (const char *,size_t)>,bool,const TinyProcessLib::Config &) noexcept': cannot convert argument 1 from 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' to 'const std::vector<TinyProcessLib::Process::string_type,std::allocator<TinyProcessLib::Process::string_type>> &'
%SRC_DIR%\src\libclang\libclang_parser.cpp(251): note: Reason: cannot convert from 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' to 'const std::vector<TinyProcessLib::Process::string_type,std::allocator<TinyProcessLib::Process::string_type>>'
%SRC_DIR%\src\libclang\libclang_parser.cpp(251): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

The problem here seems to be that cppast is calling into tiny-process-library with a std::string. However, when UNICODE is set on windows, tiny-process-library is expecting a std::wstring, namely it defines:

#ifdef _WIN32
  typedef unsigned long id_type; // Process id type
  typedef void *fd_type;         // File descriptor type
#ifdef UNICODE
  typedef std::wstring string_type;
#else
  typedef std::string string_type;
#endif

So, I don't know much about Windows but I guess this could essentially be fixed by using std::wstring to store the path to the clang binary on Windows. So, we probably need the same #ifdef to select which string type to use here.

If this sounds like a good plan to you @foonathan, I am happy to produce a PR for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions