Skip to content

Only use ENCLOS with R (< 4.5.0) #1459

@eddelbuettel

Description

@eddelbuettel

Seen at r-universe after the latest merge, and micro version increase:

Image

Can reproduce with 'R Under development (unstable) (2026-03-04 r89536)' from two days ago:

  test_environments.R...........    0 tests    using C++ compiler: ‘g++-15 (Ubuntu 15.2.0-4ubuntu4) 15.2.0’
  ccache g++-15 -I"/usr/local/lib/R-devel/lib/R/include" -DNDEBUG   -I"/tmp/r/Rcpp.Rcheck/Rcpp/include" -I"/tmp/r/Rcpp.Rcheck/Rcpp/tinytest/cpp" -I/usr/local/include    -fpic  -O3 -Wall -pipe -DBOOST_NO_AUTO_PTR -Wno-parentheses -Wno-ignored-attributes -flto   -c Environment.cpp -o Environment.o
  In file included from /tmp/r/Rcpp.Rcheck/Rcpp/include/Rcpp.h:39,
                   from Environment.cpp:22:
  /tmp/r/Rcpp.Rcheck/Rcpp/include/Rcpp/Environment.h: In instantiation of ‘Rcpp::Environment_Impl<StoragePolicy> Rcpp::Environment_Impl<StoragePolicy>::parent() const [with StoragePolicy = Rcpp::PreserveStorage]’:
  Environment.cpp:137:22:   required from here
    137 |     return env.parent() ;
        |            ~~~~~~~~~~^~
  /tmp/r/Rcpp.Rcheck/Rcpp/include/Rcpp/Environment.h:392:44: error: ‘ENCLOS’ was not declared in this scope
    392 |             return Environment_Impl( ENCLOS(Storage::get__()) ) ;
        |                                      ~~~~~~^~~~~~~~~~~~~~~~~~
  make: *** [/usr/local/lib/R-devel/lib/R/etc/Makeconf:199: Environment.o] Error 1
  Error in Rcpp::sourceCpp("cpp/Environment.cpp") : 
    Error 1 occurred building shared library.
  Calls: <Anonymous> ... run_test_dir -> lapply -> FUN -> eval -> eval -> <Anonymous>
  In addition: Warning messages:
  1: No function found for Rcpp::export attribute at file4060d457ff1ac.cpp:5 
  2: In sourceCpp(code = code, env = env, rebuild = rebuild, cacheDir = cacheDir,  :
    No Rcpp::export attributes or RCPP_MODULE declarations found in source
  Execution halted

and with a freshly updated R-devel with 'R Under development (unstable) (2026-03-06 r89558)'

There is also

  test_cppfunction_errors.R.....    1 tests OK using C++ compiler: ‘g++-15 (Ubuntu 15.2.0-4ubuntu4) 15.2.0’                                                                                                        
  ccache g++-15 -I"/usr/local/lib/R-devel/lib/R/include" -DNDEBUG   -I"/tmp/r/Rcpp.Rcheck/Rcpp/include" -I"/tmp/r/RtmpqqIOpf/working_dir/RtmpumNq15/sourceCpp-x86_64-pc-linux-gnu-1.1.1.5" -I/usr/local/include    
-fpic  -O3 -Wall -pipe -DBOOST_NO_AUTO_PTR -Wno-parentheses -Wno-ignored-attributes -flto   -c file481939123d30.cpp -o file481939123d30.o                                                                          
  file481939123d30.cpp:33:17: error: redefinition of ‘SEXPREC* sourceCpp_27_foo()’                                                                                                                                 
     33 | RcppExport SEXP sourceCpp_27_foo() {                                                           
        |                 ^~~~~~~~~~~~~~~~                                                                                                                                                                         
  file481939123d30.cpp:23:17: note: ‘SEXPREC* sourceCpp_27_foo()’ previously defined here                                                                                                                          
     23 | RcppExport SEXP sourceCpp_27_foo() {                                                           
        |                 ^~~~~~~~~~~~~~~~                                                               
  make: *** [/usr/local/lib/R-devel/lib/R/etc/Makeconf:199: file481939123d30.o] Error 1                  
                                                                                                         
  test_cppfunction_errors.R.....    2 tests OK 1.3s  

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions