fmt.cc 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. module;
  2. #define FMT_MODULE
  3. #ifdef _MSVC_LANG
  4. # define FMT_CPLUSPLUS _MSVC_LANG
  5. #else
  6. # define FMT_CPLUSPLUS __cplusplus
  7. #endif
  8. // Put all implementation-provided headers into the global module fragment
  9. // to prevent attachment to this module.
  10. #ifndef FMT_IMPORT_STD
  11. # include <algorithm>
  12. # include <bitset>
  13. # include <chrono>
  14. # include <cmath>
  15. # include <complex>
  16. # include <cstddef>
  17. # include <cstdint>
  18. # include <cstdio>
  19. # include <cstdlib>
  20. # include <cstring>
  21. # include <ctime>
  22. # include <exception>
  23. # if FMT_CPLUSPLUS > 202002L
  24. # include <expected>
  25. # endif
  26. # include <filesystem>
  27. # include <fstream>
  28. # include <functional>
  29. # include <iterator>
  30. # include <limits>
  31. # include <locale>
  32. # include <memory>
  33. # include <optional>
  34. # include <ostream>
  35. # include <source_location>
  36. # include <stdexcept>
  37. # include <string>
  38. # include <string_view>
  39. # include <system_error>
  40. # include <thread>
  41. # include <type_traits>
  42. # include <typeinfo>
  43. # include <utility>
  44. # include <variant>
  45. # include <vector>
  46. #else
  47. # include <limits.h>
  48. # include <stdint.h>
  49. # include <stdio.h>
  50. # include <time.h>
  51. #endif
  52. #include <cerrno>
  53. #include <climits>
  54. #include <version>
  55. #if __has_include(<cxxabi.h>)
  56. # include <cxxabi.h>
  57. #endif
  58. #if defined(_MSC_VER) || defined(__MINGW32__)
  59. # include <intrin.h>
  60. #endif
  61. #if defined __APPLE__ || defined(__FreeBSD__)
  62. # include <xlocale.h>
  63. #endif
  64. #if __has_include(<winapifamily.h>)
  65. # include <winapifamily.h>
  66. #endif
  67. #if (__has_include(<fcntl.h>) || defined(__APPLE__) || \
  68. defined(__linux__)) && \
  69. (!defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP))
  70. # include <fcntl.h>
  71. # include <sys/stat.h>
  72. # include <sys/types.h>
  73. # ifndef _WIN32
  74. # include <unistd.h>
  75. # else
  76. # include <io.h>
  77. # endif
  78. #endif
  79. #ifdef _WIN32
  80. # if defined(__GLIBCXX__)
  81. # include <ext/stdio_filebuf.h>
  82. # include <ext/stdio_sync_filebuf.h>
  83. # endif
  84. # define WIN32_LEAN_AND_MEAN
  85. # include <windows.h>
  86. #endif
  87. export module fmt;
  88. #ifdef FMT_IMPORT_STD
  89. import std;
  90. #endif
  91. #define FMT_EXPORT export
  92. #define FMT_BEGIN_EXPORT export {
  93. #define FMT_END_EXPORT }
  94. // If you define FMT_ATTACH_TO_GLOBAL_MODULE
  95. // - all declarations are detached from module 'fmt'
  96. // - the module behaves like a traditional static library, too
  97. // - all library symbols are mangled traditionally
  98. // - you can mix TUs with either importing or #including the {fmt} API
  99. #ifdef FMT_ATTACH_TO_GLOBAL_MODULE
  100. extern "C++" {
  101. #endif
  102. #ifndef FMT_OS
  103. # define FMT_OS 1
  104. #endif
  105. // All library-provided declarations and definitions must be in the module
  106. // purview to be exported.
  107. #include "fmt/args.h"
  108. #include "fmt/chrono.h"
  109. #include "fmt/color.h"
  110. #include "fmt/compile.h"
  111. #include "fmt/format.h"
  112. #if FMT_OS
  113. # include "fmt/os.h"
  114. #endif
  115. #include "fmt/ostream.h"
  116. #include "fmt/printf.h"
  117. #include "fmt/ranges.h"
  118. #include "fmt/std.h"
  119. #include "fmt/xchar.h"
  120. #ifdef FMT_ATTACH_TO_GLOBAL_MODULE
  121. }
  122. #endif
  123. // gcc doesn't yet implement private module fragments
  124. #if !FMT_GCC_VERSION
  125. module :private;
  126. #endif
  127. #ifdef FMT_ATTACH_TO_GLOBAL_MODULE
  128. extern "C++" {
  129. #endif
  130. #if FMT_HAS_INCLUDE("format.cc")
  131. # include "format.cc"
  132. #endif
  133. #if FMT_OS && FMT_HAS_INCLUDE("os.cc")
  134. # include "os.cc"
  135. #endif
  136. #ifdef FMT_ATTACH_TO_GLOBAL_MODULE
  137. }
  138. #endif