Skip to content

Commit 09cd186

Browse files
committed
fix: Correctly wrap system includes and FastReadMMap struct with preprocessor directives for cross-platform compatibility
1 parent df7ac48 commit 09cd186

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

weilycoder/fast-io.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@
55
#include <cstdint>
66
#include <cstdio>
77
#include <limits>
8+
9+
#if defined(__linux__) || defined(__unix__) || defined(__APPLE__)
810
#include <sys/mman.h>
911
#include <sys/stat.h>
1012
#include <unistd.h>
13+
#endif
1114

1215
namespace weilycoder {
16+
#if defined(__linux__) || defined(__unix__) || defined(__APPLE__)
1317
struct FastReadMMap {
1418
size_t file_size;
1519
char *data, *pos;
@@ -42,6 +46,7 @@ struct FastReadMMap {
4246

4347
inline char operator()() { return getchar(); }
4448
};
49+
#endif
4550

4651
template <size_t buffer_size = 1 << 20> struct FastReadFRead {
4752
char buf[buffer_size], *pos = buf, *end = buf;
@@ -197,8 +202,10 @@ template <typename Reader, typename Writer, bool debug = false> struct FastIO {
197202
}
198203
};
199204

205+
#if defined(__linux__) || defined(__unix__) || defined(__APPLE__)
200206
template <bool debug = false>
201207
using FastIOStd = FastIO<FastReadMMap, FastWriteFWrite<>, debug>;
208+
#endif
202209

203210
template <bool debug = false>
204211
using FastIOFile = FastIO<FastReadFRead<>, FastWriteFWrite<>, debug>;

0 commit comments

Comments
 (0)