diff --git a/NEWS.md b/NEWS.md index bc7b59e..374d5a0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # glue (development version) +* Add `$(C_VISIBILITY)` to compiler flags to hide internal symbols from the dll (#284 @lionel-). + # glue 1.6.2 * Modify a test for better forward compatibility with R. diff --git a/src/Makevars b/src/Makevars new file mode 100644 index 0000000..bf5eb42 --- /dev/null +++ b/src/Makevars @@ -0,0 +1 @@ +PKG_CFLAGS = $(C_VISIBILITY) diff --git a/src/init.c b/src/init.c index c43e462..3f4c51f 100644 --- a/src/init.c +++ b/src/init.c @@ -3,6 +3,11 @@ #include #include // for NULL +// Compile with `C_VISIBILITY = -fvisibility=hidden` if you link to +// this library +#include +#define export attribute_visible extern + /* .Call calls */ extern SEXP glue_(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP trim_(SEXP); @@ -12,6 +17,7 @@ static const R_CallMethodDef CallEntries[] = { {"trim_", (DL_FUNC)&trim_, 1}, {NULL, NULL, 0}}; +export void R_init_glue(DllInfo* dll) { R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); R_useDynamicSymbols(dll, FALSE);