[Rd] hello World problem
Prof Brian Ripley
ripley at stats.ox.ac.uk
Thu Jan 12 16:50:39 CET 2006
On Thu, 12 Jan 2006, Romain Francois wrote:
> Hi,
>
> I'm trying to build a simple R package 'helloWorld' with just one
> function that prints 'hello World' on the C side.
> I agree that it is completely useless, but I just start mixing R and C.
>
> My C file is as follows :
>
> #include <stdio.h>
> void helloWorld() {
> printf("hello world !\n") ;
> }
>
> When I call it from R, here is what happens :
> R> .C("helloWorld", PACKAGE = "helloWorld")
> hello world !
> list()
>
> is it normal that 'list()' is printed ?
Yes. That is the return value of .C(). (It is not normal to call .C() at
the toplevel, rather as part of a function.) The value section of the
help page says
The functions '.C' and '.Fortran' return a list similar to the
'...' list of arguments passed in, but reflecting any changes made
by the C or Fortran code.
You have no ... args, so get an empty list.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-devel
mailing list