From sfalcon at fhcrc.org  Wed Jul 25 18:01:18 2007
From: sfalcon at fhcrc.org (Seth Falcon)
Date: Wed, 25 Jul 2007 09:01:18 -0700
Subject: [Rd] Using R_MakeExternalPtr
In-Reply-To: <11785023.post@talk.nabble.com> (Jonathan Zhou's message of "Wed,
	25 Jul 2007 08:35:57 -0700 (PDT)")
References: <11785023.post@talk.nabble.com>
Message-ID: <m2ps2gv5f5.fsf@ziti.local>

Jonathan Zhou <jonathan.zhou at utoronto.ca> writes:

> Hi all, 
>
> I've been writing a package and I've run into a problem that I'm unsure how
> to solve.  I am looking to pass a C++ class object to R so that it may be
> passed back to another C++ function later on to be used.  I'm quite new to R
> and this is my first time writing a package, so I hope you can bear with me.  
>
> The following is how I create the class and use R_MakeExternalPtr().  This
> occurs in a function called "soamInit": 
>     Session* sesPtr = conPtr->createSession(attributes);
>     void* temp = session;

It isn't clear from your example, are you sure that temp is valid at
this point?

>     SEXP out = R_MakeExternalPtr(temp, R_NilValue, R_NilValue);

I was expecting to see:

      SEXP out = R_MakeExternalPtr((void *)sesPtr, R_NilValue, R_NilValue);

+ seth

-- 
Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center
http://bioconductor.org



[Rd] Using R_MakeExternalPtr
Seth Falcon