Skip to content

Commit 186f44f

Browse files
committed
New header version/arma.h for 'legacy' and 'current' arma choice
1 parent b7a9d07 commit 186f44f

File tree

10 files changed

+129
-12
lines changed

10 files changed

+129
-12
lines changed

ChangeLog

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
1-
2025-08-28 Dirk Eddelbuettel <[email protected]>
1+
2025-08-29 Dirk Eddelbuettel <[email protected]>
22

33
* DESCRIPTION (Version, Date): RcppArmadillo 15.0.1-1 (unreleased)
44
* inst/NEWS.Rd: Idem
55
* configure.ac: Idem
66
* configure: Idem
77

8+
* inst/include/RcppArmadillo/version/arma.h: Add version check logic
9+
driven by user-select #define and compilation standard
10+
* inst/include/RcppArmadillo.h: Ensure new header is included
11+
* inst/include/RcppArmadillo/Light: Ditto
12+
* inst/include/RcppArmadillo/Lighter: Ditto
13+
* inst/include/RcppArmadillo/Lightest: Ditto
14+
* inst/include/RcppArmadillo/RcppArmadillo: Ditto
15+
* inst/include/RcppArmadillo/interface/RcppArmadilloForward.h: Pick
16+
'current' or 'legacy' based on selection made
17+
* src/Makevars.in: Select current version via #define
18+
* src/Makevars.win: Ditto
19+
820
2025-08-27 Dirk Eddelbuettel <[email protected]>
921

1022
* inst/include/RcppArmadilloExtensions/fixprob.h: Replace deprecated

inst/include/RcppArmadillo.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
#error "The file 'Rcpp.h' should not be included. Please correct to include only 'RcppArmadillo.h'."
2626
#endif
2727

28+
// Deal with Armadillo 14.6.3 (fallback) versus 15.0.* (or later, preference) selection
29+
#include <RcppArmadillo/version/arma.h>
30+
2831
// Set up actual #include <armadillo> after first #include <RcppArmadilloConfig> and more config
2932
#include <RcppArmadillo/interface/RcppArmadilloForward.h>
3033

inst/include/RcppArmadillo/Light

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
// as standard 'one-dimension' objects -- as opposed to the matrix form we imposed
3131
#define RCPP_ARMADILLO_RETURN_ANYVEC_AS_VECTOR
3232

33+
// Deal with Armadillo 14.6.3 (fallback) versus 15.0.* (or later, preference) selection
34+
#include <RcppArmadillo/version/arma.h>
35+
3336
// Set up actual #include <armadillo> after first #include <RcppArmadilloConfig> and more config
3437
#include <RcppArmadillo/interface/RcppArmadilloForward.h>
3538

inst/include/RcppArmadillo/Lighter

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
// as standard 'one-dimension' objects -- as opposed to the matrix form we imposed
3131
#define RCPP_ARMADILLO_RETURN_ANYVEC_AS_VECTOR
3232

33+
// Deal with Armadillo 14.6.3 (fallback) versus 15.0.* (or later, preference) selection
34+
#include <RcppArmadillo/version/arma.h>
35+
3336
// Set up actual #include <armadillo> after first #include <RcppArmadilloConfig> and more config
3437
#include <RcppArmadillo/interface/RcppArmadilloForward.h>
3538

inst/include/RcppArmadillo/Lightest

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
// as standard 'one-dimension' objects -- as opposed to the matrix form we imposed
3131
#define RCPP_ARMADILLO_RETURN_ANYVEC_AS_VECTOR
3232

33+
// Deal with Armadillo 14.6.3 (fallback) versus 15.0.* (or later, preference) selection
34+
#include <RcppArmadillo/version/arma.h>
35+
3336
// Set up actual #include <armadillo> after first #include <RcppArmadilloConfig> and more config
3437
#include <RcppArmadillo/interface/RcppArmadilloForward.h>
3538

inst/include/RcppArmadillo/RcppArmadillo

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
// as standard 'one-dimension' objects -- as opposed to the matrix form we imposed
3131
#define RCPP_ARMADILLO_RETURN_ANYVEC_AS_VECTOR
3232

33+
// Deal with Armadillo 14.6.3 (fallback) versus 15.0.* (or later, preference) selection
34+
#include <RcppArmadillo/version/arma.h>
35+
3336
// Set up actual #include <armadillo> after first #include <RcppArmadilloConfig> and more config
3437
#include <RcppArmadillo/interface/RcppArmadilloForward.h>
3538

inst/include/RcppArmadillo/interface/RcppArmadilloForward.h

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
//
1+
22
// RcppArmadilloForward.h: Rcpp/Armadillo glue
33
//
4-
// Copyright (C) 2010 - 2023 Dirk Eddelbuettel, Romain Francois and Douglas Bates
5-
// Copyright (C) 2019 - 2023 Conrad Sanderson
4+
// Copyright (C) 2010 - 2014 Dirk Eddelbuettel, Romain Francois and Douglas Bates
5+
// Copyright (C) 2015 - 2025 Dirk Eddelbuettel
6+
// Copyright (C) 2019 - 2025 Conrad Sanderson
67
//
78
// This file is part of RcppArmadillo.
89
//
@@ -46,23 +47,36 @@
4647
// installation of Armadillo
4748
#define ARMA_DONT_USE_WRAPPER
4849

49-
#if __cplusplus >= 201402L
50-
// Armadillo 15.0 (rc)
50+
// See version/arma.h header for the (user and/or compilation) drive selection of these defines
51+
#if defined(ARMA_SELECTED_CURRENT_VERSION)
52+
53+
// we include Armadillo 15.0.1 here
54+
//#pragma message("Using compilation with current Armadillo version.")
55+
56+
// Armadillo 15.0.1 or later
5157
#include "current/armadillo"
52-
#else
53-
// we include Armadillo 14.6.2 here -- the last version to not require C++14
54-
#pragma message("Using fallback compilation with Armadillo 14.6.2 under C++11. Please consider removing the C++11 compilation standard directive.")
58+
59+
#elif defined(ARMA_SELECTED_LEGACY_VERSION)
60+
61+
// we include Armadillo 14.6.3 here
62+
//#pragma message("Using fallback compilation with Armadillo 14.6.3.")
5563

5664
// Armadillo has deprecation warnings (which RcppArmadillo suppressed at time to
5765
// minimise issies at CRAN). Should your package display any, and you decide
5866
// _not_ to fix the root causes (see RcppArmadillo GitHub Issues #391 and #402
5967
// for details) then defining the following macro will help. You can add a
6068
// #define in your source code before including the RcppArmadillo header, or add
6169
// a -DARMA_IGNORE_DEPRECATED_MARKER to the PKG_CPPFLAGS in src/Makevars.
62-
// Renabling globally for Armadillo 14.6.2 release
70+
//
71+
// Renabling globally again for Armadillo 14.6.* as too many packages trigger this
6372
#define ARMA_IGNORE_DEPRECATED_MARKER
6473

6574
#include "legacy/armadillo"
75+
76+
#else
77+
78+
#error "Neither 'current' nor 'legacy' version selected. Ensure you use proper entry point headers."
79+
6680
#endif
6781

6882
/* forward declarations */
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
2+
// version/arma.h: Armadillo version selection
3+
//
4+
// Copyright (C) 2025-current Dirk Eddelbuettel
5+
//
6+
// This file is part of RcppArmadillo.
7+
//
8+
// RcppArmadillo 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+
// RcppArmadillo 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 RcppArmadillo. If not, see <http://www.gnu.org/licenses/>.
20+
21+
#ifndef RcppArmadillo__version__arma__h
22+
#define RcppArmadillo__version__arma__h
23+
24+
25+
// Purpose: By explicitly defining or undefining a variable the 'defined(...) that
26+
// is in RcppArmadilloForward.h works as expected
27+
28+
29+
// Sanity check: Cannot select both current and legacy but only one
30+
#if defined(ARMA_USE_CURRENT) && defined(ARMA_USE_LEGACY)
31+
#error "Do not select both 'current' and 'legacy', only one choice is possible."
32+
#endif
33+
34+
// Sanity check: Cannot select current under C++11
35+
#if defined(ARMA_USE_CURRENT) && __cplusplus <= 201103L
36+
#error "Do not select 'current' with C++11 (or older) as 'current' requires C++14 or newer."
37+
#endif
38+
39+
// Carefully check and set if the user has -DARMA_USE_CURRENT
40+
// This can be set in src/Makevars(.win) via PKG_CPPFLAGS (or equivalent)
41+
#if defined(ARMA_USE_CURRENT)
42+
#define ARMA_SELECTED_CURRENT_VERSION
43+
#else
44+
#undef ARMA_SELECTED_CURRENT_VERSION
45+
#endif
46+
47+
// Carefully check and set if the user has -DARMA_USE_LEGACY
48+
// This can be set in src/Makevars(.win) via PKG_CPPFLAGS (or equivalent)
49+
#if defined(ARMA_USE_LEGACY)
50+
#define ARMA_SELECTED_LEGACY_VERSION
51+
#else
52+
#undef ARMA_SELECTED_LEGACY_VERSION
53+
#endif
54+
55+
// Fallback: Use 'legacy' and warn.
56+
// This toggle can be turned to default to 'current' (allowing a legacy override) which we plan
57+
// to do after a (sufficiently long) adjustment period
58+
#if !defined(ARMA_SELECTED_LEGACY_VERSION) && !defined(ARMA_SELECTED_CURRENT_VERSION)
59+
// Show messages, adjusted for compilation standard (as we also want to move on from C++11)
60+
// We plan to 'at some point' flip to for C++14
61+
#if __cplusplus < 201402L
62+
#pragma message("Using fallback compilation with Armadillo 14.6.3. Please consider defining -DARMA_USE_CURRENT and also removing C++11 compilation directive")
63+
// Define selector used in RcppArmadilloForward.h
64+
#define ARMA_SELECTED_LEGACY_VERSION
65+
#undef ARMA_SELECTED_CURRENT_VERSION
66+
#else
67+
#pragma message("Using fallback compilation with Armadillo 14.6.3. Please consider defining -DARMA_USE_CURRENT")
68+
// Define selector used in RcppArmadilloForward.h
69+
// It is our intention to select current here after transition instead of legacy
70+
#define ARMA_SELECTED_LEGACY_VERSION
71+
#undef ARMA_SELECTED_CURRENT_VERSION
72+
#endif
73+
#endif
74+
75+
76+
#endif

src/Makevars.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
## -*- mode: makefile; -*-
22

3-
PKG_CPPFLAGS = -I../inst/include
3+
PKG_CPPFLAGS = -I../inst/include -DARMA_USE_CURRENT
44
PKG_CXXFLAGS = @OPENMP_FLAG@
55
PKG_LIBS= @OPENMP_FLAG@ $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)

src/Makevars.win

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
## -*- mode: makefile; -*-
22

3-
PKG_CXXFLAGS = -I../inst/include -I. $(SHLIB_OPENMP_CXXFLAGS)
3+
PKG_CXXFLAGS = -I../inst/include -I. $(SHLIB_OPENMP_CXXFLAGS) -DARMA_USE_CURRENT
44
PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)

0 commit comments

Comments
 (0)