我无法找到这方面的文件.它看起来像R源代码使用NewEnvironment和R_NewHashedEnv,但它们都不在公共标题中,所以看起来它们不能作为用户使用.我应该使用什么功能(或什么行代码)来生成新的ENVSXP?
你要allocSExp:
/* C code in foo.c */
#include "Rinternals.h"
SEXP foo() {
SEXP res = allocSExp(ENVSXP);
return res;
}
Run Code Online (Sandbox Code Playgroud)
> # R code (after running R CMD SHLIB foo.c)
> dyn.load("foo.dll")
> .Call("foo")
<environment: 0x016a4084>
Run Code Online (Sandbox Code Playgroud)