Skip to content

Commit ab7e5eb

Browse files
committed
more appropriate workaround
1 parent a0c1213 commit ab7e5eb

File tree

4 files changed

+76
-3
lines changed

4 files changed

+76
-3
lines changed

ChangeLog

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
2015-01-15 Kevin Ushey <[email protected]>
22

3-
* inst/include/RcppCommon.h: remove leaked macros
4-
'major', 'minor' and 'makedev' from sys/sysmacros.h
3+
* inst/include/Rcpp/platform/sysmacros.h: remove leaked macros
4+
'major', 'minor', 'makedev' from <sys/sysmacros.h>
5+
* inst/include/RcppCommon.h: ditto
6+
* inst/unitTests/cpp/Vector.cpp: simple test
57

68
2015-01-08 Dirk Eddelbuettel <[email protected]>
79

810
* inst/examples/OpenMP/GNUmakefile: Renamed from Makefile because it
911
contains GNU make extentions (which we happen to like)
1012
* inst/examples/ConvolveBenchmarks: Ditto
11-
13+
1214
2015-01-02 Kevin Ushey <[email protected]>
1315

1416
* inst/include/Rcpp/sugar/functions/setdiff.h: fix for setequals
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// sysmacros.h: Rcpp R/C++ interface class library -- avoid sysmacros pollution
2+
//
3+
// Copyright (C) 2015 Dirk Eddelbuettel, Romain Francois, and Kevin Ushey
4+
//
5+
// This file is part of Rcpp.
6+
//
7+
// Rcpp is free software: you can redistribute it and/or modify it
8+
// under the terms of the GNU General Public License as published by
9+
// the Free Software Foundation, either version 2 of the License, or
10+
// (at your option) any later version.
11+
//
12+
// Rcpp is distributed in the hope that it will be useful, but
13+
// WITHOUT ANY WARRANTY; without even the implied warranty of
14+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
// GNU General Public License for more details.
16+
//
17+
// You should have received a copy of the GNU General Public License
18+
// along with Rcpp. If not, see <http://www.gnu.org/Licenses/>.
19+
20+
#ifndef RCPP__PLATFORM__SYSMACROS_H
21+
#define RCPP__PLATFORM__SYSMACROS_H
22+
23+
// include <sys/sysmacros.h>, and then remove stupid
24+
// 'major', 'minor' and 'makedev' defines. this works
25+
// around Rinternals.h eventually including this header
26+
// and letting the macros leak through
27+
#if defined(__GNUC__) && !defined(__APPLE__)
28+
29+
# ifdef major
30+
# define RCPP_HAS_MAJOR_MACRO
31+
# pragma push_macro("major")
32+
# endif
33+
34+
# ifdef minor
35+
# define RCPP_HAS_MINOR_MACRO
36+
# pragma push_macro("minor")
37+
# endif
38+
39+
# ifdef makedev
40+
# define RCPP_HAS_MAKEDEV_MACRO
41+
# pragma push_macro("makedev")
42+
# endif
43+
44+
# include <sys/sysmacros.h>
45+
46+
# undef major
47+
# undef minor
48+
# undef makedev
49+
50+
# ifdef RCPP_HAS_MAJOR_MACRO
51+
# pragma pop_macro("major")
52+
# endif
53+
54+
# ifdef RCPP_HAS_MINOR_MACRO
55+
# pragma pop_macro("minor")
56+
# endif
57+
58+
# ifdef RCPP_HAS_MAKEDEV_MACRO
59+
# pragma pop_macro("makedev")
60+
# endif
61+
62+
#endif
63+
64+
#endif /* RCPP__PLATFORM__SYSMACROS_H */

inst/include/RcppCommon.h

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

33+
#include <Rcpp/platform/sysmacros.h>
34+
3335
// include <sys/sysmacros.h>, and then remove stupid
3436
// 'major', 'minor' and 'makedev' defines. this works
3537
// around Rinternals.h eventually including this header

inst/unitTests/cpp/Vector.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,3 +761,8 @@ LogicalVector logical_vector_from_bool_assign() {
761761
LogicalVector result = true;
762762
return result;
763763
}
764+
765+
// [[Rcpp::export]]
766+
void no_op(int major) {
767+
int minor = 1;
768+
}

0 commit comments

Comments
 (0)