diff --git a/ChangeLog b/ChangeLog index 9911a8173..b08ef1f73 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2025-11-24 Dirk Eddelbuettel + + * inst/include/Rcpp/r/check_r_headers.h: Add RCPP_NO_R_HEADERS_CHECK + override to skip new check + +2025-11-23 Dirk Eddelbuettel + + * inst/include/Rcpp/r/check_r_headers.h: New header to check if R.h + or related R headers were installed first + * inst/include/RcppCommon.h: Call new header as first thing + 2025-11-04 Dirk Eddelbuettel * .github/workflows/macos.yaml (jobs): Roll macos-13 to macos-14 diff --git a/inst/include/Rcpp/r/check_r_headers.h b/inst/include/Rcpp/r/check_r_headers.h new file mode 100644 index 000000000..9bddb5619 --- /dev/null +++ b/inst/include/Rcpp/r/check_r_headers.h @@ -0,0 +1,44 @@ +// check_r_headers.h: Rcpp R/C++ interface class library -- R header check +// +// Copyright (C) 2025 - current Dirk Eddelbuettel +// +// This file is part of Rcpp. +// +// Rcpp is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 2 of the License, or +// (at your option) any later version. +// +// Rcpp is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Rcpp. If not, see . + +#ifndef RCPP__CHECK__R__HEADERS__H +#define RCPP__CHECK__R__HEADERS__H + +// Allow an escape hatch +#if !defined(RCPP_NO_R_HEADERS_CHECK) + + #if defined(R_R_H) && defined(USING_R) + #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" + #endif + + #if defined(RINTERFACE_H_) + #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" + #endif + + #if defined(R_INTERNALS_H_) + #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" + #endif + + #if defined(R_DEFINES_H_) + #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" + #endif + +#endif // escape hatch '!defined(RCPP_NO_R_HEADERS_CHECK)' + +#endif // header guard diff --git a/inst/include/RcppCommon.h b/inst/include/RcppCommon.h index 8f28fd035..03d5739f2 100644 --- a/inst/include/RcppCommon.h +++ b/inst/include/RcppCommon.h @@ -4,7 +4,7 @@ // // Copyright (C) 2008 - 2009 Dirk Eddelbuettel // Copyright (C) 2009 - 2020 Dirk Eddelbuettel and Romain Francois -// Copyright (C) 2021 Dirk Eddelbuettel, Romain Francois and Iñaki Ucar +// Copyright (C) 2021 - 2025 Dirk Eddelbuettel, Romain Francois and Iñaki Ucar // // This file is part of Rcpp. // @@ -27,6 +27,7 @@ // #define RCPP_DEBUG_LEVEL 1 // #define RCPP_DEBUG_MODULE_LEVEL 1 +#include #include #include