[Rcpp-devel] Are there any C++ function name restrictions?

Asis Hallab asis.hallab at gmail.com
Wed May 29 15:20:53 CEST 2013


Dear Rcpp Experts,

hopefully this question of mine is not too stupid.

Well, I am a greenhorn with Rcpp and my C/C++ expertise is quite dusty.

I generated a new Rccp package and changed the hello_world function.
The attached Rcpp Code stops working if I rename the method
"rcpp_hello_world" to
"conditionalProbabilityTables". The error I get is:
"conditionalProbabilityTables" not available for .Call() for package "PhyloFun"

I swear the only thing I changed was the function name. Hence my question:
Are there any restrictions I am unaware of?

I searched the web for "rcpp function name restrictions" and such, but
could not find anythig related.

The Rcpp Code I generated with Rcpp.package.skeleton( name="PhyloFun" )

//
// Header File:
//
#ifndef _PhyloFun_pp_RCPP_HELLO_WORLD_H
#define _PhyloFun_pp_RCPP_HELLO_WORLD_H

#include <Rcpp.h>
#ifdef _OPENMP
   #include <omp.h>
#else
   #define omp_set_num_thread(x) 1
#endif

RcppExport SEXP rcpp_hello_world( SEXP uniqueEdgeLengths, SEXP annos, SEXP
    stringifiedAnnotations, SEXP annotsMutationProbTableList, SEXP
    mutTblLengthColIndx, SEXP pMutColIndx, SEXP unknownAnnot, SEXP nThreads ) ;

#endif

//
// CPP File
//
#include "rcpp_hello_world.h"

    // CharacterVector x = CharacterVector::create( "foo", "bar" )  ;
    // NumericVector y   = NumericVector::create( 0.0, 1.0 ) ;
    // List z            = List::create( x, y ) ;
    //
    // return z ;
SEXP rcpp_hello_world( SEXP uniqueEdgeLengths, SEXP annos, SEXP
    stringifiedAnnotations, SEXP annotsMutationProbTableList, SEXP
    mutTblLengthColIndx, SEXP pMutColIndx, SEXP unknownAnnot, SEXP nThreads ){
    using namespace Rcpp ;

  BEGIN_RCPP
    NumericVector numberThreads = NumericVector( nThreads );
    omp_set_num_threads( numberThreads(0) );

    NumericVector edgeLengths = NumericVector( uniqueEdgeLengths );
    List cpts = List();

    #pragma omp parallel for
    for ( int i = 0; i < edgeLengths.size(); i++ )
    {
      // NumericVector cpt = conditionalProbabilityTable( edgeLengths( i ),
      //     annos, stringifiedAnnotations,  annotsMutationProbTableList,
      //     mutTblLengthColIndx,  pMutColIndx,  unknownAnnot );
      // Named cptListEntry = Named( edgeLengths( i ) );
      // cptListEntry = cpt;
      NumericMatrix cpt = NumericMatrix( 1000, 1000 );
      cpts.push_back( cpt );
    }
    return( wrap( cpts ) );
  END_RCPP
}

//
// Makevars
//
PKG_CXXFLAGS="-fopenmp"
PKG_LIBS=$(shell $(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()")
$(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) -fopenmp

Help will be much appreciated!
Cheers!


More information about the Rcpp-devel mailing list