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 missing includes in fmt.cc #3994

Merged
merged 2 commits into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ function(add_module_library name)
target_compile_options(${name} PUBLIC -fmodules-ts)
endif ()

target_compile_definitions(${name} PRIVATE FMT_MODULE)

if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.28 AND CMAKE_GENERATOR STREQUAL "Ninja")
target_sources(${name} PUBLIC FILE_SET fmt TYPE CXX_MODULES FILES ${sources})
else()
Expand Down
9 changes: 6 additions & 3 deletions include/fmt/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
#ifndef FMT_BASE_H_
#define FMT_BASE_H_

#include <limits.h> // CHAR_BIT
#include <stdio.h> // FILE
#include <string.h> // strlen
// c headers are preferable for performance reasons
#ifndef FMT_MODULE
# include <limits.h> // CHAR_BIT
# include <stdio.h> // FILE
# include <string.h> // strlen
#endif

#ifndef FMT_IMPORT_STD
// <cstddef> is also included transitively from <type_traits>.
Expand Down
3 changes: 1 addition & 2 deletions include/fmt/chrono.h
Original file line number Diff line number Diff line change
Expand Up @@ -2144,8 +2144,7 @@ struct formatter<day, Char> : private formatter<std::tm, Char> {
if (use_tm_formatter_) return formatter<std::tm, Char>::format(time, ctx);
detail::get_locale loc(false, ctx.locale());
auto w = detail::tm_writer<decltype(ctx.out()), Char>(loc, ctx.out(), time);
w.on_day_of_month(detail::numeric_system::standard,
detail::pad_type::zero);
w.on_day_of_month(detail::numeric_system::standard, detail::pad_type::zero);
return w.out();
}
};
Expand Down
5 changes: 5 additions & 0 deletions src/fmt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ module;
# include <algorithm>
# include <chrono>
# include <cmath>
# include <complex>
# include <cstddef>
# include <cstdint>
# include <cstdio>
# include <cstdlib>
# include <cstring>
# include <ctime>
# include <exception>
# include <expected>
# include <filesystem>
# include <fstream>
# include <functional>
Expand All @@ -22,6 +24,7 @@ module;
# include <memory>
# include <optional>
# include <ostream>
# include <source_location>
# include <stdexcept>
# include <string>
# include <string_view>
Expand Down Expand Up @@ -104,7 +107,9 @@ extern "C++" {
#if FMT_OS
# include "fmt/os.h"
#endif
#include "fmt/ostream.h"
#include "fmt/printf.h"
#include "fmt/ranges.h"
#include "fmt/std.h"
#include "fmt/xchar.h"

Expand Down
Loading