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

Fix rtpmidid client not building #135

Conversation

Momomentum
Copy link
Contributor

When building with gcc 14.2.1 and libfmt 11.0.2 I get the following error:

[ 35%] Building CXX object src/CMakeFiles/rtpmidid2-static.dir/settings.cpp.o
In file included from /usr/include/fmt/format.h:41,
                 from rtpmidid/include/rtpmidid/logger.hpp:23,
                 from rtpmidid/src/midipeer.hpp:22,
                 from rtpmidid/src/precompile.hpp:23,
                 from rtpmidid/build/src/CMakeFiles/rtpmidid2-static.dir/cmake_pch.hxx:5,
                 from <command-line>:
/usr/include/fmt/base.h: In instantiation of ‘constexpr fmt::v11::detail::value<Context> fmt::v11::detail::make_arg(T&) [with bool PACKED = true; Context = fmt::v11::context; T = const rtpmididns::settings_t::alsa_hw_auto_export_type_e; typename std::enable_if<PACKED, int>::type <anonymous> = 0]’:
/usr/include/fmt/base.h:2018:74:   required from ‘constexpr fmt::v11::detail::format_arg_store<Context, NUM_ARGS, 0, DESC> fmt::v11::make_format_args(T& ...) [with Context = context; T = {const rtpmididns::settings_t::alsa_hw_auto_export_type_e}; long unsigned int NUM_ARGS = 1; long unsigned int NUM_NAMED_ARGS = 0; long long unsigned int DESC = 15; typename std::enable_if<(NUM_NAMED_ARGS == 0), int>::type <anonymous> = 0]’
 2018 |   return {{detail::make_arg<NUM_ARGS <= detail::max_packed_args, Context>(
      |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
 2019 |       args)...}};
      |       ~~~~~
/usr/include/fmt/format.h:4365:44:   required from ‘std::string fmt::v11::format(format_string<T ...>, T&& ...) [with T = {const rtpmididns::settings_t::alsa_hw_auto_export_type_e&}; std::string = std::__cxx11::basic_string<char>; format_string<T ...> = basic_format_string<char, const rtpmididns::settings_t::alsa_hw_auto_export_type_e&>]’
 4365 |   return vformat(fmt, fmt::make_format_args(args...));
      |                       ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
rtpmidid/src/settings.cpp:129:24:   required from here
  129 |   result += fmt::format("type: {} ", data.type);
      |             ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/fmt/base.h:1641:63: error: ‘fmt::v11::detail::type_is_unformattable_for<const rtpmididns::settings_t::alsa_hw_auto_export_type_e, char> _’ has incomplete type
 1641 |     type_is_unformattable_for<T, typename Context::char_type> _;
      |                                                               ^
/usr/include/fmt/base.h:1644:7: error: static assertion failed: Cannot format an argument. To make type T formattable provide a formatter<T> specialization: https://fmt.dev/latest/api.html#udt
 1644 |       formattable,

It seems libfmt does not like format_as to be in a different namespace. This moves the function into the rtpmididns namespace.

Alternatively I could also implement the template specialization.

It seems libfmt does not like format_as to be in a different namespace.
This moves the function into the rtpmididns namespace.
@Momomentum
Copy link
Contributor Author

@davidmoreno Could you have a look at this?

@DerScherenmann
Copy link

I can only compile this with #include <sys/types.h> in midi_normalizer.hpp

@davidmoreno
Copy link
Owner

Hi,

I just created a branch newlogger that tries to use the std::format when available (C++20 with some library support), and also adds some macros to ease the pain of custom formatters. I think it should solve this compilation problem. If std::format is not available still uses the libfmt, but as it uses some macros to standardize our custom formatters, I think it should work.

Do you mind having a look?

@DerScherenmann
Copy link

Hi,

the branch newlogger does indeed build, although I haven't tested functionality yet.

@Momomentum
Copy link
Contributor Author

Hi David. Sorry I only saw this now. Works fine for me, thanks so much!

@Momomentum Momomentum closed this Nov 11, 2024
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

Successfully merging this pull request may close these issues.

3 participants