Skip to content

.cpp file changes not reflected after successive call to cpp_source #143

@sccmckenzie

Description

@sccmckenzie

After initial call to cpp_source('file.cpp'), any subsequent calls to cpp_source('file.cpp') appear to have no effect on the actual compiled function - regardless of changes made to file.cpp.

file.cpp

#include "cpp11.hpp"
using namespace cpp11;

[[cpp11::register]]
int one() {
  return 1;
}

R sesssion

library(cpp11)
cpp_source("file.cpp")

one()
#> [1] 1

Make changes to file.cpp (return 2 instead of 1), save...

#include "cpp11.hpp"
using namespace cpp11;

[[cpp11::register]]
int one() {
  return 2; // change to 2
}

Back to R session. Return value is still 1.

rm(one)
cpp_source("file.cpp")

one()
#> [1] 1

I have tried reinstalling cpp11 and Rtools - same result.

sessioninfo::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value                       
#>  version  R version 4.0.3 (2020-10-10)
#>  os       Windows 10 x64              
#>  system   x86_64, mingw32             
#>  ui       RTerm                       
#>  language (EN)                        
#>  collate  English_United States.1252  
#>  ctype    English_United States.1252  
#>  tz       America/Chicago             
#>  date     2021-01-08                  
#> 
#> - Packages -------------------------------------------------------------------
#>  package     * version date       lib source        
#>  assertthat    0.2.1   2019-03-21 [1] CRAN (R 4.0.2)
#>  cli           2.2.0   2020-11-20 [1] CRAN (R 4.0.3)
#>  cpp11       * 0.2.4   2020-11-05 [1] CRAN (R 4.0.3)
#>  crayon        1.3.4   2017-09-16 [1] CRAN (R 4.0.2)
#>  digest        0.6.25  2020-02-23 [1] CRAN (R 4.0.2)
#>  evaluate      0.14    2019-05-28 [1] CRAN (R 4.0.2)
#>  fansi         0.4.1   2020-01-08 [1] CRAN (R 4.0.2)
#>  glue          1.4.2   2020-08-27 [1] CRAN (R 4.0.2)
#>  highr         0.8     2019-03-20 [1] CRAN (R 4.0.2)
#>  htmltools     0.5.0   2020-06-16 [1] CRAN (R 4.0.2)
#>  knitr         1.30    2020-09-22 [1] CRAN (R 4.0.2)
#>  magrittr      1.5     2014-11-22 [1] CRAN (R 4.0.2)
#>  rlang         0.4.8   2020-10-08 [1] CRAN (R 4.0.3)
#>  rmarkdown     2.4     2020-09-30 [1] CRAN (R 4.0.2)
#>  sessioninfo   1.1.1   2018-11-05 [1] CRAN (R 4.0.2)
#>  stringi       1.5.3   2020-09-09 [1] CRAN (R 4.0.2)
#>  stringr       1.4.0   2019-02-10 [1] CRAN (R 4.0.2)
#>  withr         2.3.0   2020-09-22 [1] CRAN (R 4.0.2)
#>  xfun          0.18    2020-09-29 [1] CRAN (R 4.0.2)
#>  yaml          2.2.1   2020-02-01 [1] CRAN (R 4.0.2)
#> 
#> [1] C:/Users/Scott/Documents/R/win-library/4.0
#> [2] C:/Program Files/R/R-4.0.3/library

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions