简体   繁体   English

在MAC OSX的同一R会话中调用两个.Call(Rcpp)函数

[英]Calling two .Call (Rcpp) function in the same R session in MAC OSX

I am facing a strange problem. 我面临一个奇怪的问题。 The program works fine on a linux machine but on a MAC OSX. 该程序在Linux机器上运行良好,但在MAC OSX上运行良好。 The R program crashes. R程序崩溃。 I have 2 R functions. 我有2个R函数。 They call two different C++ functions as follows. 他们如下调用两个不同的C ++函数。 I call these R functions from a third R function. 我从第三个R函数中调用这些R函数。 While using a mac the results from the first .call(main1)function are generated and when the other .call(main2) is called the program crashes saying input parameters not found. 使用Mac时,将生成第一个.call(main1)函数的结果,并且在调用另一个.call(main2)时,程序崩溃,提示找不到输入参数。 When I run them the two functions independently in in separate R sessions they work fine. 当我在单独的R会话中分别运行这两个函数时,它们可以正常工作。 I just can't figure out the exception. 我只是想不出例外。 It works fine on a linux machine 在Linux机器上工作正常

> getResults()
{
   funct1() {
       .call(main1, s1, s2)
   }
   funct2() {
       .call(main2, s1, s2)
   }
}

This not a reproducible example so we cannot offer specifics. 这不是可复制的示例,因此我们无法提供具体信息。 Can you provide a full example exhibiting your issue? 您能否提供一个完整的例子来展示您的问题?

In general, you can do any one of 通常,您可以执行以下任一操作

  • use 'Rcpp attributes' and sourceCpp() and just declare your two functions 使用“ Rcpp属性”和sourceCpp()并声明两个函数
  • call cppFunction() twice, or cxxfunction() from the inline package 调用cppFunction()两次,或cxxfunction()从列直插封装
  • write a package 写一个包

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM