Skip to content

[Rcpp-devel] error while calling function in loop

8 messages · Dirk Eddelbuettel, nandan amar, Sean Robert McGuffee +1 more

#
Ohh Then i sud select reply to all

Thanks Dirk,
But RInside R(argc, argv) is not a variable .
How can I declare it globally or share its instance.
If it is not related to R/Rcpp please leave some related pointer.
regards,
On 26 March 2011 18:38, Dirk Eddelbuettel <edd at debian.org> wrote:

            

  
    
#
On 26 March 2011 at 19:06, nandan amar wrote:
| Ohh Then i sud select reply to all
| 
| Thanks Dirk,
| But RInside R(argc, argv) is not a variable .

If R is not a variable here, what is it?

| How can I declare it globally or share its instance.
| If it is not related to R/Rcpp please leave some related pointer.

Sorry, but you simply need to read some more about C++ and or
programming. Google for 'good c++ book'. There is a free one I like at

   http://www.icce.rug.nl/documents/cplusplus/

which is also included in Debian and Ubuntu as a package.

Dirk
#
Thanks Dirk,
It worked when I  pass RInside variable by reference.
Thanks for the link, i am  learning these things.
On 26 March 2011 19:48, Dirk Eddelbuettel <edd at debian.org> wrote:

            

  
    
1 day later
#
RInside R(argc, argv); //this would appear to be a class called RInside
definining a variable called R initialized with argc and argv variables.

To declare it globally, you would need to define it inside a *.cpp file
once, and only once. Usually this is easiest to do at the top of a *.cpp
file that uses it. Then do the same thing in other files that use it, but in
those cases, place the term "extern" in front of the declaration.

Example:

RInside R; //this is a declaration
extern RInside R; //this is a line for another file that lets the compiler
know it is declared in another *.cpp file.

Then inside your main function where you must be to get the argc and argv
variables, you could then initialize the class:
R=RInside(argc,argv);

I haven't ever used this class, and my instructions assume that a default
constructor for RInside is accessible to you. If it were not, then you would
have to make a pointer to it in the global scope and then assign it by
reference:

//outside of all {}'s at the top of a *.cpp file:
RInside *Rptr; //this is a pointer of type RInside declaration
extern RInside *Rptr; //this is a line for another file that lets the
compiler know Rptr is declared in another *.cpp file

//inside main
RInside R(argc, argv);
Rptr=&R;

I hope this helps,

Sean
On 3/26/11 10:18 AM, "Dirk Eddelbuettel" <edd at debian.org> wrote:

            
#
How hard is it to set up the list with a default reply to address of the
list?
On 3/26/11 9:36 AM, "nandan amar" <nandan.amar at gmail.com> wrote:

            
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20110328/38faf90f/attachment.htm>
#
On Mon, Mar 28, 2011 at 1:31 PM, Sean Robert McGuffee
<sean.mcguffee at gmail.com> wrote:
Making the change, not difficult.  Convincing Dirk to make the change,
very difficult.

Google the phrase "Reply-to munging considered harmful".
#
Judging from Dirk's "Reply on the damn list. How hard is that?" statement, I
imagine his is already convinced...
On 3/28/11 2:49 PM, "Douglas Bates" <bates at stat.wisc.edu> wrote:

            
#
Thanks Sean.
Its really helpful.
On 29 March 2011 00:00, Sean Robert McGuffee <sean.mcguffee at gmail.com>wrote: