Message-ID: <4E8BAE49.4070700@xtra.co.nz>
Date: 2011-10-05T01:09:29Z
From: Rolf Turner
Subject: Problem with .C
In-Reply-To: <4E8AF632.1030803@mathematik.uni-marburg.de>
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 R --arch x64 CMD SHLIB foo.c and
> loaded it into R with dyn.load().
>
> What can be the cause of such behaviour?
> Again, the C-funcion itself works, but not if called from R.
It's impossible to say, with such minimal information, but a reasonable
guess is that there is a problem with the declaration of "x" and "y" in
foo.c. These would (I think) need to be declared as double *, not double,
when foo is called from .C().
cheers,
Rolf Turner