traitecoevo / plant

Trait-Driven Models of Ecology and Evolution :evergreen_tree:
https://traitecoevo.github.io/plant
53 stars 20 forks source link

Rcpp and Boost compiler warnings #311

Closed aornugent closed 2 years ago

aornugent commented 2 years ago

I've been playing whack-a-warning to try tidy up our compiler garbage. Only two remain, and they appear to stem from the Rcpp and BH (Boost Headers) packages. Appreciate any suggestions on how these can be avoided.

Inline Rcpp functions

g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I../inst/include/ -I'/home/a/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/include' -I'/home/a/R/x86_64-pc-linux-gnu-library/4.0/BH/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -UNDEBUG -Wall -pedantic -g -O0 -fdiagnostics-color=always -c control.cpp -o control.o
   In file included from /home/a/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/include/RcppCommon.h:119,
                    from ../inst/include/plant/qk.h:7,
                    from ../inst/include/plant/qag.h:5,
                    from ../inst/include/plant/control.h:5,
                    from control.cpp:1:
   /home/a/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/include/Rcpp/exceptions.h:59:21: warning: inline function 'void Rcpp::exception::record_stack_trace()' used but never defined
      59 |         inline void record_stack_trace();
         |                     ^~~~~~~~~~~~~~~~~~
   /home/a/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/include/Rcpp/exceptions.h:54:21: warning: inline function 'void Rcpp::exception::copy_stack_trace_to_r() const' used but never defined
      54 |         inline void copy_stack_trace_to_r() const;
         |                     ^~~~~~~~~~~~~~~~~~~~~
   In file included from /home/a/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/include/Rcpp/protection/protection.h:23,
                    from /home/a/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/include/RcppCommon.h:117,
                    from ../inst/include/plant/qk.h:7,
                    from ../inst/include/plant/qag.h:5,
                    from ../inst/include/plant/control.h:5,
                    from control.cpp:1:
   /home/a/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/include/Rcpp/protection/Armor.h:38:23: warning: inline function 'Rcpp::Armor<T>& Rcpp::Armor<T>::operator=(const U&) [with U = SEXPREC*; T = SEXPREC*]' used but never defined
      38 |         inline Armor& operator=( const U& x ) ;
         |                       ^~~~~~~~

Unnecessary parentheses


g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I../inst/include/ -I'/home/a/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/include' -I'/home/a/R/x86_64-pc-linux-gnu-library/4.0/BH/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -UNDEBUG -Wall -pedantic -g -O0 -fdiagnostics-color=always -c ff16_cohort.cpp -o ff16_cohort.o
   In file included from /home/a/R/x86_64-pc-linux-gnu-library/4.0/BH/include/boost/mpl/aux_/na_assert.hpp:23,
                    from /home/a/R/x86_64-pc-linux-gnu-library/4.0/BH/include/boost/mpl/arg.hpp:25,
                    from /home/a/R/x86_64-pc-linux-gnu-library/4.0/BH/include/boost/mpl/placeholders.hpp:24,
                    from /home/a/R/x86_64-pc-linux-gnu-library/4.0/BH/include/boost/mpl/apply.hpp:24,
                    from /home/a/R/x86_64-pc-linux-gnu-library/4.0/BH/include/boost/mpl/aux_/iter_apply.hpp:17,
                    from /home/a/R/x86_64-pc-linux-gnu-library/4.0/BH/include/boost/mpl/aux_/find_if_pred.hpp:14,
                    from /home/a/R/x86_64-pc-linux-gnu-library/4.0/BH/include/boost/mpl/find_if.hpp:17,
                    from /home/a/R/x86_64-pc-linux-gnu-library/4.0/BH/include/boost/mpl/find.hpp:17,
                    from /home/a/R/x86_64-pc-linux-gnu-library/4.0/BH/include/boost/mpl/aux_/contains_impl.hpp:20,
                    from /home/a/R/x86_64-pc-linux-gnu-library/4.0/BH/include/boost/mpl/contains.hpp:20,
                    from /home/a/R/x86_64-pc-linux-gnu-library/4.0/BH/include/boost/math/policies/policy.hpp:10,
                    from /home/a/R/x86_64-pc-linux-gnu-library/4.0/BH/include/boost/math/special_functions/math_fwd.hpp:29,
                    from /home/a/R/x86_64-pc-linux-gnu-library/4.0/BH/include/boost/math/special_functions/sign.hpp:17,
                    from /home/a/R/x86_64-pc-linux-gnu-library/4.0/BH/include/boost/math/tools/roots.hpp:34,
                    from ../inst/include/plant/uniroot.h:8,
                    from ../inst/include/plant/strategy.h:8,
                    from ../inst/include/plant.h:21,
                    from ff16_cohort.cpp:1:
   /home/a/R/x86_64-pc-linux-gnu-library/4.0/BH/include/boost/mpl/assert.hpp:194:21: warning: unnecessary parentheses in declaration of 'assert_arg' [-Wparentheses]
     194 | failed ************ (Pred::************
         |                     ^
   /home/a/R/x86_64-pc-linux-gnu-library/4.0/BH/include/boost/mpl/assert.hpp:199:21: warning: unnecessary parentheses in declaration of 'assert_not_arg' [-Wparentheses]
     199 | failed ************ (boost::mpl::not_<Pred>::************
         |  
devmitch commented 2 years ago

Silencing the R compiler warnings involved changing the src/Makevars file (done in #318) to use the -isystem flag instead of -I as suggested by https://stackoverflow.com/questions/1867065/how-to-suppress-gcc-warnings-from-library-headers.

aornugent commented 2 years ago

Heaps quieter after #318 - thanks!