diff --git a/CMakeLists.txt b/CMakeLists.txt index ea883b80..a2c69cf9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,7 +83,7 @@ endfunction() # Define the fmt library, its includes and the needed defines. # format.cc is added to FMT_HEADERS for the header-only configuration. add_headers(FMT_HEADERS core.h format.h format.cc locale.h ostream.h ostream.cc - printf.h printf.cc string.h time.h) + printf.h string.h time.h) if (HAVE_OPEN) add_headers(FMT_HEADERS posix.h) add_headers(FMT_SOURCES posix.cc) diff --git a/include/fmt/printf.cc b/include/fmt/printf.cc deleted file mode 100644 index bc43bbf9..00000000 --- a/include/fmt/printf.cc +++ /dev/null @@ -1,21 +0,0 @@ -#include "fmt/printf.h" - -namespace fmt { - -template -void printf(basic_writer &w, basic_string_view format, - format_args args); - -FMT_FUNC int vfprintf(std::FILE *f, string_view format, printf_args args) { - memory_buffer buffer; - printf(buffer, format, args); - std::size_t size = buffer.size(); - return std::fwrite( - buffer.data(), 1, size, f) < size ? -1 : static_cast(size); -} - -#ifndef FMT_HEADER_ONLY -template void printf_context::format(buffer &); -template void printf_context::format(wbuffer &); -#endif -} diff --git a/include/fmt/printf.h b/include/fmt/printf.h index 9a8d052c..540e2d7a 100644 --- a/include/fmt/printf.h +++ b/include/fmt/printf.h @@ -555,7 +555,13 @@ inline std::wstring sprintf(wstring_view format_str, const Args & ... args) { return vsprintf(format_str, vargs); } -FMT_API int vfprintf(std::FILE *f, string_view format, printf_args args); +inline int vfprintf(std::FILE *f, string_view format, printf_args args) { + memory_buffer buffer; + printf(buffer, format, args); + std::size_t size = buffer.size(); + return std::fwrite( + buffer.data(), 1, size, f) < size ? -1 : static_cast(size); +} /** \rst diff --git a/test/format-impl-test.cc b/test/format-impl-test.cc index 11bdacc0..671858ae 100644 --- a/test/format-impl-test.cc +++ b/test/format-impl-test.cc @@ -30,7 +30,7 @@ // Include format.cc instead of format.h to test implementation-specific stuff. #include "fmt/format.cc" -#include "fmt/printf.cc" +#include "fmt/printf.h" #include #include