[R] problem when I Call C subfunction in void function

John McKown john.archie.mckown at gmail.com
Wed Aug 27 14:09:10 CEST 2014

On Wed, Aug 27, 2014 at 4:58 AM, eguichard <elie.guichard at inserm.fr> wrote:
> Hi everybody,
> I am including some C code in R program using the .C interface.
> I would like use a C subfunction calling by C void function.
> /double essai (double Px[], int tailleP)
> {
>         Rprintf ("I print Px %d\t", Px[1]);
>         return 57;
> }
> void test_essai (double *Px, int *tailleP, double *res)
> {
>         *res = essai(*Px, *tailleP);

This line is wrong. Try:
           *res = essi(Px, *tailleP);

Note that double *Px and double Px[] are basically different ways to
say pretty much the same thing. At least in C. Not in C++ or many
other languages. But further discussion would be even more off topic.

> }/
> This program doesn’t work. When I compile it, I have the following error :
> “In function ‘test_essai :
> -       Error: incompatible type for argument 1 of ‘essai’
> -       Note : expected ‘double*’ but argument is of type ‘double’ ”
> Does anyone have solution ?
> Thank all, Elie

There is nothing more pleasant than traveling and meeting new people!
Genghis Khan

Maranatha! <><
John McKown

More information about the R-help mailing list