Skip to content

Commit 618d0ef

Browse files
committed
better workaround re: macro leakage from Rinterals -> sysmacros chain
1 parent f26aa09 commit 618d0ef

File tree

5 files changed

+81
-75
lines changed

5 files changed

+81
-75
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ src/*.dll
99
Rcpp.pro
1010
Rcpp.pro.user
1111
*.autosave
12+
.#*

ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2015-01-19 Kevin Ushey <[email protected]>
2+
3+
* inst/include/Rcpp/r/headers.h: move R headers inclusion to own file;
4+
move sysmacros.h workarounds to here
5+
* inst/include/RcppCommon.h: idem
6+
* inst/include/Rcpp/platform/sysmacros.h: idem
7+
18
2015-01-19 Dirk Eddelbuettel <[email protected]>
29

310
* vignettes/Rcpp.bib: Updated to current package versions

inst/include/Rcpp/platform/sysmacros.h

Lines changed: 0 additions & 64 deletions
This file was deleted.

inst/include/Rcpp/r/headers.h

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// headers.h: Rcpp R/C++ interface class library -- R headers
2+
//
3+
// Copyright (C) 2008 - 2009 Dirk Eddelbuettel
4+
// Copyright (C) 2009 - 2013 Dirk Eddelbuettel and Romain Francois
5+
//
6+
// This file is part of Rcpp.
7+
//
8+
// Rcpp is free software: you can redistribute it and/or modify it
9+
// under the terms of the GNU General Public License as published by
10+
// the Free Software Foundation, either version 2 of the License, or
11+
// (at your option) any later version.
12+
//
13+
// Rcpp is distributed in the hope that it will be useful, but
14+
// WITHOUT ANY WARRANTY; without even the implied warranty of
15+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
// GNU General Public License for more details.
17+
//
18+
// You should have received a copy of the GNU General Public License
19+
// along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
20+
21+
#ifndef RCPP__R__HEADERS__H
22+
#define RCPP__R__HEADERS__H
23+
24+
// include R headers, but set R_NO_REMAP and access everything via Rf_ prefixes
25+
#define MAXELTSIZE 8192
26+
#define R_NO_REMAP
27+
28+
// prevent some macro pollution when including R headers
29+
// in particular, on Linux, gcc 'leaks' the 'major',
30+
// 'minor' and 'makedev' macros on Linux; we prevent
31+
// letting those leak in after including any R headers
32+
33+
#ifdef major
34+
# define RCPP_HAS_MAJOR_MACRO
35+
# pragma push_macro("major")
36+
#endif
37+
38+
#ifdef minor
39+
# define RCPP_HAS_MINOR_MACRO
40+
# pragma push_macro("minor")
41+
#endif
42+
43+
#ifdef makedev
44+
# define RCPP_HAS_MAKEDEV_MACRO
45+
# pragma push_macro("makedev")
46+
#endif
47+
48+
#include <R.h>
49+
#include <Rinternals.h>
50+
#include <R_ext/Complex.h>
51+
#include <R_ext/Parse.h>
52+
#include <R_ext/Rdynload.h>
53+
#include <Rversion.h>
54+
55+
#undef major
56+
#undef minor
57+
#undef makedev
58+
59+
#ifdef RCPP_HAS_MAJOR_MACRO
60+
# pragma pop_macro("major")
61+
#endif
62+
63+
#ifdef RCPP_HAS_MINOR_MACRO
64+
# pragma pop_macro("minor")
65+
#endif
66+
67+
#ifdef RCPP_HAS_MAKEDEV_MACRO
68+
# pragma pop_macro("makedev")
69+
#endif
70+
71+
#endif /* RCPP__R__HEADERS__H */

inst/include/RcppCommon.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,8 @@
3030
#include <Rcpp/config.h>
3131
#include <Rcpp/macros/macros.h>
3232

33-
#include <Rcpp/platform/sysmacros.h>
34-
35-
// include R headers, but set R_NO_REMAP and access everything via Rf_ prefixes
36-
#define MAXELTSIZE 8192
37-
#define R_NO_REMAP
38-
#include <R.h>
39-
#include <Rinternals.h>
40-
#include <R_ext/Complex.h>
41-
#include <R_ext/Parse.h>
42-
#include <R_ext/Rdynload.h>
43-
#include <Rversion.h>
33+
34+
#include <Rcpp/r/headers.h>
4435

4536
/**
4637
* \brief Rcpp API

0 commit comments

Comments
 (0)