From ripley at stats.ox.ac.uk  Thu Jan 12 16:50:39 2006
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Thu, 12 Jan 2006 15:50:39 +0000 (GMT)
Subject: [Rd] hello World problem
In-Reply-To: <43C679C6.7050709@free.fr>
References: <43C679C6.7050709@free.fr>
Message-ID: <Pine.LNX.4.61.0601121549040.436@gannet.stats>

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



[Rd] hello World problem
Prof Brian Ripley