Cannot compile R package with Rcpp

  c++, devtools, r, r-package, rcpp

I’m trying to build a R package and I’m using Rcpp in one of my functions. I can load the function with sourceCpp("~/Desktop/trial/src/code.cpp") and I don’t have any issues using the function on it’s own, but I get errors when trying to add it and build the package. When I run devtools::load_all() I get the following error,

  System command 'R' failed, exit status: 1, stdout + stderr (last 10 lines):
E>     Rcpp::traits::input_parameter< string >::type delim(delimSEXP);
E>                                    ^~~~~~
E>                                    String
E> /Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/Rcpp/String.h:49:11: note: 'String' declared here
E>     class String {
E>           ^
E> 12 errors generated.
E> make: *** [RcppExports.o] Error 1
E> ERROR: compilation failed for package ‘trial’
E> * removing ‘/private/var/folders/52/y1qz8q711pd8cv60r_687c6m0000gn/T/RtmpOO3W0e/devtools_install_aae030821fbc/trial’ 

I’m using the string split function from . Is there something in the cpp code that conflicts with adding it to a R package? Any help would be appreciated!

Source: Windows Questions C++