Hi Joseph,
On 19 February 2020 at 21:59, Joseph Wood wrote: | As the subject says, what is the best way to specify a minimum | compiler version in the DESCRIPTION file. In short: you can't. Read on. | I only found 2 packages on CRAN that have a minimum requirement for | GCC, however they both seem to be divergent in style. I could not find | anything definitive in Writing R Extensions. | | I don't want to imply that one absolutely needs a specific compiler | (i.e. if you are using Mac clang is used so I wouldn't expect Mac user | to jump through a bunch of hoops to use a specific gcc compiler), I | just want to give users of differing systems something informative to | help them out. | | There is more information here: https://github.com/jwood000/RcppAlgos/issues/13 I have a super-old snippet in RQuantLib's configure.ac: AC_PROG_CXX if test "${GXX}" = yes; then gxx_version=`${CXX} -v 2>&1 | grep "^.*g.. version" | \\ sed -e 's/^.*g.. version *//'` case ${gxx_version} in 1.*|2.*) AC_MSG_WARN([Only g++ version 3.0 or greater can be used with RQuantib.]) AC_MSG_ERROR([Please use a different compiler.]) ;; 4.6.*|4.7.*|4.8.*|4.9.*|5.*|6.*|7.*|8.*|9.*|10.*) gxx_newer_than_45="-fpermissive" ;; esac fi That is from years past when we worried about g++-3 :) but still sets the -fpermissve option where possible. I am also doing something similar in RcppArmadillo: ## Check the C++ compiler using the CXX value set AC_PROG_CXX ## If it is g++, we have GXX set so let's examine it if test "${GXX}" = yes; then AC_MSG_CHECKING([whether g++ version is sufficient]) gxx_version=$(${CXX} -v 2>&1 | awk '/^.*g.. version/ {print $3}') case ${gxx_version} in 1.*|2.*|3.*|4.0.*|4.1.*|4.2.*|4.3.*|4.4.*|4.5.*|4.6.*|4.7.0|4.7.1) AC_MSG_RESULT([no]) AC_MSG_WARN([Only g++ version 4.7.2 or greater can be used with RcppArmadillo.]) AC_MSG_ERROR([Please use a different compiler.]) ;; 4.7.*|4.8.*|4.9.*|5.0*|5.1*|5.2*|5.3*) AC_MSG_RESULT([yes, but without OpenMP as version ${gxx_version} (Armadillo constraint)]) ## we know this one is bad can_use_openmp="no" ;; 5.4*|5.5*|5.6*|5.7*|5.8*|5.9*|6.*|7.*|8.*|9.*|10.*|11.*|12.*) AC_MSG_RESULT([yes, with OpenMP as version ${gxx_version}]) ## we know this one is good, yay can_use_openmp="yes" ;; *) AC_MSG_RESULT([almost]) AC_MSG_WARN([Compiler self-identifies as being compliant with GNUC extensions but is not g++.]) ## we know nothing, so no can_use_openmp="no" ;; esac fi I now need something similar myself -- but I think the better test is NOT to test for minimum g++ or clang++ versions ... but to check the C++ standard directly. If you need a minium C++ version (as I do in a package to be updated), see this answer SO: https://stackoverflow.com/questions/2324658/how-to-determine-the-version-of-the-c-standard-used-by-the-compiler/7132549#7132549 and to test for __cplusplus. Hth, Dirk -- http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org ______________________________________________ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel