Hello,

I'd like to be able to simply define functions like this :

SEXP foo( IntegerVector x ){
        // .. do something with x
}

instead of this:

SEXP foo( SEXP x){
        IntegerVector xx(x) ;
}

and there is something in do_dotcode (I don't know what) that prevents 
this. With this file :

=====================
#include <Rcpp.h>

using namespace Rcpp;

extern "C" {
        SEXP foo ( IntegerVector x) ;
}

SEXP foo( IntegerVector x ) {
        Rprintf( "hello <%p> \n", x.asSexp() ) ;
        return x ;
}
=====================

compiled into a so with :

rom...@naxos /tmp $ export PKG_LIBS=`Rscript -e "Rcpp:::LdFlags()"`
rom...@naxos /tmp $ export PKG_CXXFLAGS=`Rscript -e "Rcpp:::CxxFlags()"`

and then :


require( Rcpp)
dyn.load( "foo.so" )
.Call( "foo", 1:10 )


This prints :

rom...@naxos /tmp $ Rscript test.R
Le chargement a nécessité le package : Rcpp
hello <0x100843178>
NULL


but, If I use this file instead:

=====================
#include <Rcpp.h>

using namespace Rcpp;

SEXP foo_( IntegerVector x ) ;

extern "C" {
        SEXP foo ( SEXP x ){ return foo_(x) ; }
}

SEXP foo_( IntegerVector x ) {
        Rprintf( "hello <%p> \n", x.asSexp() ) ;
        return x ;
}
=====================

it works:

rom...@naxos /tmp $ Rscript test.R
Le chargement a nécessité le package : Rcpp
hello <0x102cc0cd8>
  [1]  1  2  3  4  5  6  7  8  9 10


In the first case, we are still able to determine the correct function, 
otherwise it would not print anything but the object is not correctly 
passed through.

Any ideas ?

Romain

-- 
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/OIXN : raster images and RImageJ
|- http://tr.im/OcQe : Rcpp 0.7.7
`- http://tr.im/O1wO : highlight 0.1-5

_______________________________________________
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to