[Rcpp-devel] how to get rid of the warning message: no graphics system to unregister

Darren Cook darren at dcook.org
Tue Feb 14 06:39:49 CET 2012


> Here is the test code I first used to call the R function from C++
> program. At the end, the warning message came out.
> 
> double two_sample_logrank(RInside R, double* t, int* d,
>      int sample_size){ ...

I think you've worked this out, but I thought this line should have been:
   double two_sample_logrank(RInside &R, double* t, int* d,
     int sample_size){ ...

Dirk/Romain: A quick look at the source [1] shows no copy constructor
has been defined, which means a default one will be created that will do
copy-by-value on all member variables... and that looks dangerous.

How about making copy private [2]? E.g. adding this section at the end
of the class definition in RInside.h:

  private:
   RInside(const RInside&){
	throw std::logic_error("Copy not allowed");
	}
   RInside& operator= (const RInside&){
	throw std::logic_error("Assignment not allowed");
	}

(I had them throw in order to catch any copy attempt from inside the
RInside class itself.)

If copy-by-value is safe, and/or copy is needed in certain
circumstances, then ignore all that :-)

Darren

[1]:
https://r-forge.r-project.org/scm/viewvc.php/pkg/inst/include/RInside.h?view=markup&root=rinside
https://r-forge.r-project.org/scm/viewvc.php/pkg/src/RInside.cpp?view=markup&revision=227&root=rinside

[2]: http://www.devx.com/tips/Tip/12570


More information about the Rcpp-devel mailing list