Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upfix three bugs in quick ref vignette #933
Conversation
> Rcpp::evalCpp('NumericVector::create(Named["foo"] = 1.0,_["bar"] = 2.0 )')
file419870ee27e6.cpp: In function ‘SEXPREC* get_value()’:
file419870ee27e6.cpp:6:65: error: invalid types ‘<unresolved overloaded function type>[const char [4]]’ for array subscript
SEXP get_value(){ return wrap( NumericVector::create(Named["foo"] = 1.0,_["bar"] = 2.0 ) ) ; }
^
make: *** [file419870ee27e6.o] Error 1
g++ -I"/usr/share/R/include" -DNDEBUG -I"/home/zhuoer/.local/lib/R/Rcpp/include" -I"/tmp/Rtmp7XEiDX/sourceCpp-x86_64-pc-linux-gnu-1.0.0" -fpic -g -O2 -fdebug-prefix-map=/build/r-base-oUvOgu/r-base-3.5.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c file419870ee27e6.cpp -o file419870ee27e6.o
/usr/lib/R/etc/Makeconf:168: recipe for target 'file419870ee27e6.o' failed
Error in sourceCpp(code = code, env = env, rebuild = rebuild, cacheDir = cacheDir, :
Error 1 occurred building shared library.
> Rcpp::evalCpp('NumericVector::create(Named("foo") = 1.0,_["bar"] = 2.0 )')
foo bar
1 2
I also adjust the relative position of " Special environments" and "Obtain an R environment", since `Environment::global_env()` is introduced in the former
```r
Rcpp::evalCpp('Environment::global_env().ls()')
```
```
file59666c8ac214.cpp: In function ‘SEXPREC* get_value()’:
file59666c8ac214.cpp:6:61: error: no matching function for call to ‘Rcpp::Environment_Impl<Rcpp::PreserveStorage>::ls()’
SEXP get_value(){ return wrap( Environment::global_env().ls() ) ; }
^
In file included from /home/zhuoer/.local/lib/R/Rcpp/include/Rcpp.h:38:0,
from file59666c8ac214.cpp:1:
/home/zhuoer/.local/lib/R/Rcpp/include/Rcpp/Environment.h:85:14: note: candidate: SEXPREC* Rcpp::Environment_Impl<StoragePolicy>::ls(bool) const [with StoragePolicy = Rcpp::PreserveStorage; SEXP = SEXPREC*]
SEXP ls(bool all) const {
^~
/home/zhuoer/.local/lib/R/Rcpp/include/Rcpp/Environment.h:85:14: note: candidate expects 1 argument, 0 provided
make: *** [file59666c8ac214.o] Error 1
g++ -I"/usr/share/R/include" -DNDEBUG -I"/home/zhuoer/.local/lib/R/Rcpp/include" -I"/tmp/RtmpXtPnoL/sourceCpp-x86_64-pc-linux-gnu-1.0.0" -fpic -g -O2 -fdebug-prefix-map=/build/r-base-oUvOgu/r-base-3.5.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c file59666c8ac214.cpp -o file59666c8ac214.o
/usr/lib/R/etc/Makeconf:168: recipe for target 'file59666c8ac214.o' failed
Error in sourceCpp(code = code, env = env, rebuild = rebuild, cacheDir = cacheDir, :
Error 1 occurred building shared library.
```
```r
Rcpp::evalCpp('Environment::global_env().ls(TRUE)')
```
```
[1] ".Random.seed"
```
eddelbuettel provides another example
```r
cppFunction("CharacterVector foo() { Environment glob=Environment::global_env(); return glob.ls(true); }" )
foo()
```
```
[1] ".Random.seed" "foo"
```
|
Looks good to me, apart from a small whitespace issue in the ChangeLog I will take care of once merged! Thanks for putting this together. |
close #932