#pragma once #include #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wmissing-field-initializers" #pragma GCC diagnostic ignored "-Wunused-parameter" #include #pragma GCC diagnostic pop #include #include #include #if __has_include() && (__cpp_lib_source_location >= 201907L) #include namespace libremidi { using source_location = std::source_location; } #else namespace libremidi { struct source_location { static source_location current() noexcept { return {}; } int line() const noexcept { return -1; } int offset() const noexcept { return -1; } const char* function_name() const noexcept { return "(unknown)"; } const char* file_name() const noexcept { return "(unknown)"; } }; } #endif namespace libremidi { inline auto from_errc(int ret) noexcept { return static_cast(-ret); } /*! \brief Error callback function \param type Type of error. \param errorText Error description. Note that class behaviour is undefined after a critical error (not a warning) is reported. */ using midi_error_callback = std::function; using midi_warning_callback = std::function; } #if !defined(LIBREMIDI_LOG) #if !defined(__LIBREMIDI_DEBUG__) #define LIBREMIDI_LOG(...) \ do \ { \ } while (0) #else #include #define LIBREMIDI_LOG(...) \ do \ { \ [](auto&&... args) { \ (std::cerr << ... << args); \ std::cerr << std::endl; \ }(__VA_ARGS__); \ } while (0) #endif #endif