|
| 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 |
0 commit comments