我想在R包內編譯C++ 11下的sitmo prng。 The problematic code has been packaged and is available here.此R包的目標是提供sitmo header file以便其他包能夠使用說明中的LinkTo字段。作爲額外的獎勵,該軟件包計劃隨附Armadillo + OpenMP示例。還有一個包,mvnfast,它使用sitmo,但只在C++ 98和boost頭文件中。編譯問題與sitmo prng,c + + 11和犰狳
我認爲我收到的錯誤是特定於OS X
和clang
。我無法通過win-build在Windows上覆制它。這就是說,錯誤是:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/random:3641:44: error: non-type template argument is not a constant expression
const size_t __logR = __log2<uint64_t, _URNG::max() - _URNG::min() + uint64_t(1)>::value;
錯誤只是彈出在Rcpp dev list。這種情況下的解決方案是在C++ 98下編譯並使用boost。
後跟上述錯誤由下列說明:
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/random:3773:18: note: in instantiation of function template specialization 'std::__1::generate_canonical<double, 53, sitmo::prng_engine>' requested here
* _VSTD::generate_canonical<_RealType, numeric_limits<_RealType>::digits>(__g)
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/random:3737:17: note: in instantiation of function template specialization 'std::__1::uniform_real_distribution<double>::operator()<sitmo::prng_engine>' requested here
{return (*this)(__g, __p_);}
^
sitmo_test.cpp:77:26: note: in instantiation of function template specialization 'std::__1::uniform_real_distribution<double>::operator()<sitmo::prng_engine>' requested here
double u = distunif(engine);
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/random:3641:44: note: non-constexpr function 'max' cannot be used in a constant expression
const size_t __logR = __log2<uint64_t, _URNG::max() - _URNG::min() + uint64_t(1)>::value;
^
../inst/include/prng_engine.hpp:100:23: note: declared here
static result_type (max)() { return 0xFFFFFFFF; }
的鐺正在使用的版本是:
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.3.0
Thread model: posix
你好。我會試着去看一看,但不要今晚。我也有sitmo的東西看看...你也可以把它帶到rcpp-devel嗎? –
當然,我也會將問題發佈到rcpp-devel。 – coatless
@DirkEddelbuettel我懷疑sitmo在這裏是不對的,請看看 –