指定其他構建依賴項

要在 Rcpp 生態系統中使用其他軟體包,正確的標頭檔案可能不是 Rcpp.h 而是 Rcpp<PACKAGE>.h例如對於 RcppArmadillo )。通常需要匯入它,然後在其中宣告依賴項

// [[Rcpp::depends(Rcpp<PACKAGE>)]]

例子:

// Use the RcppArmadillo package
// Requires different header file from Rcpp.h
#include <RcppArmadillo.h>
// [[Rcpp::depends(RcppArmadillo)]]

// Use the RcppEigen package
// Requires different header file from Rcpp.h
#include <RcppEigen.h>
// [[Rcpp::depends(RcppEigen)]]