[Rcpp-devel] Bug: compileAttributes incorrectly handles Rcpp::export-ed functions with multiple arguments

JJ Allaire jj.allaire at gmail.com
Sat Jan 18 13:07:59 CET 2014


Thanks for the report and sorry it took so long to get the the bottom
of it (I had also tried reproing to no avail). This is now fixed with
https://github.com/RcppCore/Rcpp/commit/d366984e6aabc426bae7f827b9fabc69df8d707b.

J.J.

On Sat, Jan 18, 2014 at 6:41 AM, Romain Francois
<romain at r-enthusiasts.com> wrote:
>
> Le 18 janv. 2014 à 06:10, Davor Cubranic <cubranic at stat.ubc.ca> a écrit :
>
> Running compileAttributes with “verbose = TRUE” was very informative:
>
> $ Rscript -e 'Rcpp::compileAttributes(".", TRUE)'
> Exports from /Users/davor/projects/Davor/myPackage/src/rcpp_hello_world.cpp:
>    List rcpp_hello_world(NumericVector foo)
>
> Exports from
> /Users/davor/projects/Davor/myPackage/src/rcpp_hello_world.cpp~:
>    List rcpp_hello_world()
>
>
> Answer: compileAttributes interprets Emacs backup files with extension
> “.cpp~” as source files. (My fault for not zipping up the actual source
> directory but the product of "R CMD build".)
>
> Probable source of the error is in compileAttributes (Attributes.R:355):
>
>     cppFiles <- list.files(srcDir, pattern = glob2rx("*.c*”))
>
>
> Hi,
>
> This has bitten me too in various training I gave about Rcp. I guess
> [.]c(c|pp)$ would make a better pattern.
> WRE says (if you read between the lines) that c++ files are .cpp or .cc
>
> So this is a bug.
>
> Romain
>
> You need a better way to identify C++ sources. R-exts manual says R’s make
> rules use .cc and .cpp for C++. (This is supposed to be recorded in
> R_HOME/etcR_ARCH/Makeconf, so it could potentially be processed dynamically,
> although I doubt that’s really necessary.)
>
> Davor
>
>
> On Jan 17, 2014, at 4:18 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
>
>
> On 17 January 2014 at 15:32, Davor Cubranic wrote:
> | On 2014-01-17, at 2:55 PM, Dirk Eddelbuettel wrote:
> |
> | > You had two mistakes here:
> | >
> | >  i)   after you alter an interface to be used by Rcpp Attributes, you
> must
> | >       re-run the compileAttributes() function to update the files.  See
> the
> | >       vignette for details.
> |
> | What do you mean by this? Like I said, I changed the .cpp file and re-run
> |  compileAttributes. What I uploaded is the result afterwards.
>
> The equivalent of
>
>    $ cd myPackage; R -e 'Rcpp::compileAttributes(".")'
>
> For once, I launched R and typed it by hand.
>
> | >       (And if you use RStudio, this is done automagically)
> |
> | So it is by devtools, on one of the functions I regularly use in my
> workflow, perhaps "test". If it wasn't, it would be such a pain.
> |
> | >  ii)  Your C++ function did not work as the 'List z = ...' parameter
> | >       shadowed an already declared parameter from the function
> interface.
> | >       Renaming to zz or z2 works, of course.
> |
> | I fixed it and rerun compileAttributes. Still the same problem. New
> version of the package is attached.
>
> See here, based on your previous file.
>
> edd at max:/tmp/davor/myPackage$ cat src/rcpp_hello_world.cpp
>
> #include <Rcpp.h>
> using namespace Rcpp;
>
> // [[Rcpp::export]]
> List rcpp_hello_world(NumericVector z) {
>
>    CharacterVector x = CharacterVector::create( "foo", "bar" )  ;
>    NumericVector y   = NumericVector::create( 0.0, 1.0 ) ;
>    List z2           = List::create( x, y ) ;
>
>    return z2 ;
> }
> edd at max:/tmp/davor/myPackage$ R CMD check .
> * using log directory ‘/tmp/davor/myPackage/..Rcheck’
> * using R version 3.0.2 (2013-09-25)
> * using platform: x86_64-pc-linux-gnu (64-bit)
> * using session charset: UTF-8
> * checking for file ‘./DESCRIPTION’ ... OK
> * checking extension type ... Package
> * this is package ‘myPackage’ version ‘1.0’
> * checking package namespace information ... OK
> * checking package dependencies ... OK
> * checking if this is a source package ... OK
> * checking if there is a namespace ... OK
> * checking for executable files ... OK
> * checking for hidden files and directories ... NOTE
> Found the following hidden files and directories:
>  ..Rcheck
> These were most likely included in error. See section ‘Package structure’ in
> the ‘Writing R Extensions’ manual.
> * checking for portable file names ... OK
> * checking for sufficient/correct file permissions ... OK
> * checking whether package ‘myPackage’ can be installed ... WARNING
> Found the following significant warnings:
>  Warning: /tmp/davor/myPackage/man/myPackage-package.Rd:31: All text must be
> in a section
>  Warning: /tmp/davor/myPackage/man/myPackage-package.Rd:32: All text must be
> in a section
> See ‘/tmp/davor/myPackage/..Rcheck/00install.out’ for details.
> * checking installed package size ... OK
> * checking package directory ... OK
> * checking DESCRIPTION meta-information ... WARNING
> Non-standard license specification:
>  What Licence is it under ?
> Standardizable: FALSE
> * checking top-level files ... OK
> * checking for left-over files ... OK
> * checking index information ... OK
> * checking package subdirectories ... WARNING
> Found the following directory with the name of a check directory:
>  ./..Rcheck
> Most likely, these were included erroneously.
> * checking R files for non-ASCII characters ... OK
> * checking R files for syntax errors ... OK
> * checking whether the package can be loaded ... OK
> * checking whether the package can be loaded with stated dependencies ... OK
> * checking whether the package can be unloaded cleanly ... OK
> * checking whether the namespace can be loaded with stated dependencies ...
> OK
> * checking whether the namespace can be unloaded cleanly ... OK
> * checking loading without being on the library search path ... OK
> * checking dependencies in R code ... OK
> * checking S3 generic/method consistency ... OK
> * checking replacement functions ... OK
> * checking foreign function calls ... OK
> * checking R code for possible problems ... OK
> * checking Rd files ... WARNING
> prepare_Rd: myPackage-package.Rd:31: All text must be in a section
> prepare_Rd: myPackage-package.Rd:32: All text must be in a section
> prepare_Rd: myPackage-package.Rd:38-40: Dropping empty section \examples
> * checking Rd metadata ... OK
> * checking Rd cross-references ... WARNING
> Unknown package ‘<pkg>’ in Rd xrefs
> * checking for missing documentation entries ... OK
> * checking for code/documentation mismatches ... WARNING
> Codoc mismatches from documentation object 'rcpp_hello_world':
> rcpp_hello_world
>  Code: function(z)
>  Docs: function()
>  Argument names in code not in docs:
>    z
>
> * checking Rd \usage sections ... OK
> * checking Rd contents ... OK
> * checking for unstated dependencies in examples ... OK
> * checking line endings in C/C++/Fortran sources/headers ... OK
> * checking line endings in Makefiles ... OK
> * checking compilation flags in Makevars ... OK
> * checking for portable use of $(BLAS_LIBS) and $(LAPACK_LIBS) ... OK
> * checking compiled code ... OK
> * checking examples ... OK
> * checking PDF version of manual ... OK
>
> WARNING: There were 6 warnings.
> NOTE: There was 1 note.
> See
>  ‘/tmp/davor/myPackage/..Rcheck/00check.log’
> for details.
>
> edd at max:/tmp/davor/myPackage$
>
>
> Hope this help,  Dirk
>
> --
> Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
>
>
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>
>
>
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel


More information about the Rcpp-devel mailing list