Skip to content

Commit 747fc0d

Browse files
authored
Emit message if R.h included, can turn to warning (#1411)
* Add a message header * Use a dedicated header file * Add override, update ChangeLog * Listened to the robot and took his advice
1 parent dcd33d7 commit 747fc0d

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed

ChangeLog

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2025-11-24 Dirk Eddelbuettel <[email protected]>
2+
3+
* inst/include/Rcpp/r/check_r_headers.h: Add RCPP_NO_R_HEADERS_CHECK
4+
override to skip new check
5+
6+
2025-11-23 Dirk Eddelbuettel <[email protected]>
7+
8+
* inst/include/Rcpp/r/check_r_headers.h: New header to check if R.h
9+
or related R headers were installed first
10+
* inst/include/RcppCommon.h: Call new header as first thing
11+
112
2025-11-04 Dirk Eddelbuettel <[email protected]>
213

314
* .github/workflows/macos.yaml (jobs): Roll macos-13 to macos-14
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// check_r_headers.h: Rcpp R/C++ interface class library -- R header check
2+
//
3+
// Copyright (C) 2025 - current Dirk Eddelbuettel
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__CHECK__R__HEADERS__H
21+
#define RCPP__CHECK__R__HEADERS__H
22+
23+
// Allow an escape hatch
24+
#if !defined(RCPP_NO_R_HEADERS_CHECK)
25+
26+
#if defined(R_R_H) && defined(USING_R)
27+
#pragma message "R.h has been included before any Rcpp headers. This can lead to hard-to-debug errors, and is not necessary. See https://github.com/RcppCore/Rcpp/issues/1410"
28+
#endif
29+
30+
#if defined(RINTERFACE_H_)
31+
#pragma message "Rinterface.h has been included before any Rcpp headers. This can lead to hard-to-debug errors, and is not necessary. See https://github.com/RcppCore/Rcpp/issues/1410"
32+
#endif
33+
34+
#if defined(R_INTERNALS_H_)
35+
#pragma message "Rinternals.h has been included before any Rcpp headers. This can lead to hard-to-debug errors, and is not necessary. See https://github.com/RcppCore/Rcpp/issues/1410"
36+
#endif
37+
38+
#if defined(R_DEFINES_H_)
39+
#pragma message "Rdefines.h has been included before any Rcpp headers. This can lead to hard-to-debug errors, and is not necessary. See https://github.com/RcppCore/Rcpp/issues/1410"
40+
#endif
41+
42+
#endif // escape hatch '!defined(RCPP_NO_R_HEADERS_CHECK)'
43+
44+
#endif // header guard

inst/include/RcppCommon.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//
55
// Copyright (C) 2008 - 2009 Dirk Eddelbuettel
66
// Copyright (C) 2009 - 2020 Dirk Eddelbuettel and Romain Francois
7-
// Copyright (C) 2021 Dirk Eddelbuettel, Romain Francois and Iñaki Ucar
7+
// Copyright (C) 2021 - 2025 Dirk Eddelbuettel, Romain Francois and Iñaki Ucar
88
//
99
// This file is part of Rcpp.
1010
//
@@ -27,6 +27,7 @@
2727
// #define RCPP_DEBUG_LEVEL 1
2828
// #define RCPP_DEBUG_MODULE_LEVEL 1
2929

30+
#include <Rcpp/r/check_r_headers.h>
3031
#include <Rcpp/r/headers.h>
3132
#include <Rcpp/r/compat.h>
3233

0 commit comments

Comments
 (0)