hadley / r-internals

Documentation for R's internal C API
346 stars 40 forks source link

Mention STRICT_R_HEADERS #6

Open jeroen opened 8 years ago

hadley commented 8 years ago

What does it do?

jeroen commented 8 years ago

It disables a bunch of S-compatibility macros that can potentially conflict with other libraries such as Calloc, Malloc, etc.

jeroen commented 8 years ago

Here is a real world example. wingdi.h defines an ERROR macro which is also defined in R:

In file included from C:/PROGRA~1/R/R-33~1.2/include/R.h:80:0,
                 from C:/Program Files/R/R-3.3.2/library/Rcpp/include/Rcpp/r/headers.h:52,
                 from C:/Program Files/R/R-3.3.2/library/Rcpp/include/RcppCommon.h:29,
                 from C:/Program Files/R/R-3.3.2/library/Rcpp/include/Rcpp.h:27,
                 from bindings.cpp:7:
C:/PROGRA~1/R/R-33~1.2/include/R_ext/RS.h:54:0: warning: "ERROR" redefined
 #define ERROR   ),error(R_problem_buf);}
 ^
In file included from C:/Rtools/mingw_64/x86_64-w64-mingw32/include/windows.h:71:0,
                 from ../windows/tesseract-3.04.01/include/tesseract/host.h:65,
                 from ../windows/tesseract-3.04.01/include/tesseract/tesscallback.h:22,
                 from ../windows/tesseract-3.04.01/include/tesseract/baseapi.h:36,
                 from bindings.cpp:1:
C:/Rtools/mingw_64/x86_64-w64-mingw32/include/wingdi.h:75:0: note: this is the location of the previous definition
 #define ERROR 0
 ^

The problem is solved by #define STRICT_R_HEADERS.