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

<fmt/std.h> compilation failure with MinGW #3705

Closed
hchataing opened this issue Nov 6, 2023 · 4 comments
Closed

<fmt/std.h> compilation failure with MinGW #3705

hchataing opened this issue Nov 6, 2023 · 4 comments

Comments

@hchataing
Copy link

Foreword: I not able to reproduce the issue outside of the original context (building AOSP).

Triggered an error when compiling for windows with mingw instead of MSVC.
The code assumes that string_type returned by std::filesystem::path::native is wstring, when it is basic_string<char>.
This causes the following error (include paths redacted):

external/fmtlib/include/fmt/std.h:80:10: error: no matching constructor for initialization of 'to_utf8<wchar_t>'
  return to_utf8<wchar_t>(p.native(), to_utf8_error_policy::replace);
         ^                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
external/fmtlib/include/fmt/format.h:1424:12: note: candidate constructor not viable: no known conversion from 'const string_type' (aka 'const basic_string<char>') to 'basic_string_view<wchar_t>' for 1st argument
  explicit to_utf8(basic_string_view<WChar> s,
           ^
external/fmtlib/include/fmt/format.h:1418:66: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided
template <typename WChar, typename Buffer = memory_buffer> class to_utf8 {
                                                                 ^
external/fmtlib/include/fmt/format.h:1418:66: note: candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 2 were provided
external/fmtlib/include/fmt/format.h:1423:3: note: candidate constructor not viable: requires 0 arguments, but 2 were provided
  to_utf8() {}
  ^
@vitaut
Copy link
Contributor

vitaut commented Nov 7, 2023

Here's a tentative fix: 050d41e. Does it solve the problem?

@hchataing
Copy link
Author

Thanks for the quick fix 👍
There is a different compilation issue now :

external/fmtlib/include/fmt/std.h:86:3: error: no matching function for call to 'write_escaped_string'
  write_escaped_string<wchar_t>(std::back_inserter(buf), p.native());
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
external/fmtlib/include/fmt/format.h:1963:6: note: candidate function template not viable: no known conversion from 'const string_type' (aka 'const basic_string<char>') to 'basic_string_view<wchar_t>' for 2nd argument
auto write_escaped_string(OutputIt out, basic_string_view<Char> str)
     ^
external/fmtlib/include/fmt/std.h:93:13: error: redefinition of 'write_escaped_path<char>'
inline void write_escaped_path<std::filesystem::path::value_type>(
            ^
external/fmtlib/include/fmt/std.h:83:13: note: previous definition is here
inline void write_escaped_path<char>(memory_buffer& quoted,

@vitaut
Copy link
Contributor

vitaut commented Nov 7, 2023

Applied a similar fix to write_escaped_string in 4548d1e. Please let me know if it helped.

@hchataing
Copy link
Author

That solved the compilation issue, thanks !

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