Re: [R] Problem with .C

2011-10-06 Thread Grigory Alexandrovich
Hello, first thank you for your answers. I did not read the whole pdf Writing R Extension, but I read this strongly shortened introduction to this subject: http://www.math.kit.edu/stoch/~lindner/media/.c.call%20extensions.pdf I get the same error with this C-function: void test(double * b,

Re: [R] Problem with .C

2011-10-06 Thread Jan van der Laan
An obvious reason might be that your second argument should be a pointer to int. As others have mentioned, you might want to have a look at Rccp and/or inline. The documentation is good and I find it much easier to work with. For example, your example could be written as: library(Rcpp)

Re: [R] Problem with .C

2011-10-06 Thread Uwe Ligges
On 06.10.2011 14:51, Jan van der Laan wrote: An obvious reason might be that your second argument should be a pointer to int. As others have mentioned, you might want to have a look at Rccp and/or inline. The documentation is good and I find it much easier to work with. For example, your

Re: [R] Problem with .C

2011-10-06 Thread Steve Lianoglou
Hi, 2011/10/6 Uwe Ligges lig...@statistik.tu-dortmund.de: On 06.10.2011 14:51, Jan van der Laan wrote: An obvious reason might be that your second argument should be a pointer to int. As others have mentioned, you might want to have a look at Rccp and/or inline. The documentation is good

Re: [R] Problem with .C

2011-10-06 Thread Uwe Ligges
On 06.10.2011 15:41, Steve Lianoglou wrote: Hi, 2011/10/6 Uwe Liggeslig...@statistik.tu-dortmund.de: On 06.10.2011 14:51, Jan van der Laan wrote: An obvious reason might be that your second argument should be a pointer to int. As others have mentioned, you might want to have a look at

Re: [R] Problem with .C

2011-10-06 Thread Jan van der Laan
Quoting Uwe Ligges lig...@statistik.tu-dortmund.de: I don't agree that it's overkill -- you get to sidestep the whole `R CMD SHLIB ...` and `dyn.load` dance this way while you experiment with C(++) code 'live using the inline package. You need two additional packages now where you have to

[R] Problem with .C

2011-10-04 Thread Grigory Alexandrovich
Hello, I wrote a function in C, which works fine if called from the main-function in C. But as soon as I try to call this function from R like .C('foo', as.double(x), as.integer(y)), the programm crashes. I created a dll with the cmd command R --arch x64 CMD SHLIB foo.c and loaded it into

Re: [R] Problem with .C

2011-10-04 Thread Uwe Ligges
Without knowing that C code, we cannot know. Have you read Writing R Extensions carefully? I.e. take care with memory allocation and printing as mentioned in the manual. Uwe Ligges On 04.10.2011 14:04, Grigory Alexandrovich wrote: Hello, I wrote a function in C, which works fine if called

Re: [R] Problem with .C

2011-10-04 Thread Jeff Newmiller
This looks like a classic case of not reading the manual, and then compounding it by not reading the posting guide. The manual would be the Writing R Extensions pdf that comes with R or you can google it. The posting guide is referenced at the bottom of this and every other posting on this

Re: [R] Problem with .C

2011-10-04 Thread Rolf Turner
On 05/10/11 01:04, Grigory Alexandrovich wrote: Hello, I wrote a function in C, which works fine if called from the main-function in C. But as soon as I try to call this function from R like .C('foo', as.double(x), as.integer(y)), the programm crashes. I created a dll with the cmd command

Re: [R] Problem with .C

2011-10-04 Thread Steve Lianoglou
Hi, As other have said, it's very difficult to help you without an example + code to know what you are talking about. That having been said, it seems as if you are just getting your feet wet in this R -- C bridge, and I'd recommend you checkout the Rcpp and inline package to help make your life