forked from Rdatatable/data.table
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfreadR.h
23 lines (18 loc) · 1000 Bytes
/
freadR.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#ifndef dt_FREAD_R_H
#define dt_FREAD_R_H
#define STRICT_R_HEADERS // https://cran.r-project.org/doc/manuals/r-devel/R-exts.html#Error-handling
#include <R.h>
#define FREAD_MAIN_ARGS_EXTRA_FIELDS
#define FREAD_PUSH_BUFFERS_EXTRA_FIELDS \
int nStringCols; \
int nNonStringCols;
// Before error() [or warning() with options(warn=2)] call freadCleanup() to close mmp and fix :
// http://stackoverflow.com/questions/18597123/fread-data-table-locks-files
// However, msg has to be manually constructed first (rather than simply leaving construction to snprintf inside warning()
// or error()) because the msg usually points to substrings from the mmp (which is invalid after close).
// Where no halt is happening, we can just use raw Rprintf() or warning()
void __halt(bool warn, const char *format, ...); // see freadR.c
#define STOP(...) __halt(0, __VA_ARGS__)
#define DTPRINT Rprintf
#define DTWARN(...) warningsAreErrors ? __halt(1, __VA_ARGS__) : warning(__VA_ARGS__)
#endif