Closed tdhock closed 3 years ago
I confirm that putting the following line in src/Makevars will silence those warnings,
CXX_STD=CXX17
@diego-urgell the warnings I saw on my computer are
g++ -std=gnu++14 -I"/home/tdhock/lib/R/include" -DNDEBUG -I'/home/tdhock/lib/R/library/Rcpp/include' -I/usr/local/include -fpic -g -O2 -c AlgorithmInterface.cpp -o AlgorithmInterface.o
In file included from DistributionInterface.cpp:5:0,
from Segment.cpp:6,
from AlgorithmInterface.cpp:6:
GenericFactory.cpp:19:61: warning: inline variables are only available with -std=c++1z or -std=gnu++1z
inline static std::map<std::string, objectCreateMethod> regSpecs = std::map<std::string, objectCreateMethod>();
^~~~~~~~
GenericFactory.cpp: In static member function ‘static bool GenericFactory<T>::Register(std::__cxx11::string, GenericFactory<T>::objectCreateMethod)’:
GenericFactory.cpp:26:13: warning: init-statement in selection statements only available with -std=c++1z or -std=gnu++1z
if (auto it = regSpecs.find(name); it == regSpecs.end()) {
^~~~
Thanks @tdhock! This worked pretty well. Also in order to remove the "unused value" warnings, I used (void) regSpecs
(in the factories, for example) in order to indicate the compiler that those variables would not be used (the ones that are only there to instantiate the templates). Now I only get two warnings but they seem to be caused by the R.h header.
I no longer get any warnings
two options
CXX_STD = CXX11
Compilation and linking will then be done with the C++11 compiler (if any).
Packages without a src/Makevars or src/Makefile file may specify that they require C++11 for code in the src directory by including ‘C++11’ in the ‘SystemRequirements’ field of the DESCRIPTION file, e.g.
SystemRequirements: C++11