new_CppObject_xp .. constructor in 2.16; and how to configure TravisCI

Partial progress: on my Ubuntu 16.04 server, I have added a Makevars

CXX=clang++
USE_CXX11=1

and got a working version of 2.16.2. The error is now downgraded to a warning (not that I love it), but again, USE_CXX11 has not been picked up as the warning message shows. clang 3.5 is installed.

No progress yet on TravisCI where I cannot simply change the system.

clang++ -I/usr/share/R/include -DNDEBUG -I"../inst/include" -I"../inst/include/boost_not_in_BH" -I"`"/usr/lib/R/bin/Rscript" --vanilla -e "cat(system.file('include', 'src', package = 'StanHeaders'))"`" -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DFUSION_MAX_VECTOR_SIZE=12 -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/RcppEigen/include" -I"/usr/local/lib/R/site-library/BH/include" -I"/usr/local/lib/R/site-library/StanHeaders/include"    -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c lang__grammars__whitespace_grammar_inst.cpp -o lang__grammars__whitespace_grammar_inst.o
In file included from lang__grammars__whitespace_grammar_inst.cpp:19:
In file included from /usr/local/lib/R/site-library/StanHeaders/include/src/stan/lang/grammars/whitespace_grammar_inst.cpp:1:
In file included from /usr/local/lib/R/site-library/StanHeaders/include/src/stan/lang/grammars/whitespace_grammar_def.hpp:5:
In file included from /usr/local/lib/R/site-library/StanHeaders/include/src/stan/lang/grammars/semantic_actions.hpp:6:
In file included from /usr/local/lib/R/site-library/StanHeaders/include/src/stan/lang/ast.hpp:68:
/usr/local/lib/R/site-library/StanHeaders/include/src/stan/lang/ast/node/conditional_op.hpp:40:21: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
      bool has_var_ = false;
                    ^
1 warning generated.

Apparently, to get an updated compiler on Travis, you can do this:

Which means that I have to give up the elegant

https://docs.travis-ci.com/user/languages/r/

and use the old ugly style I used last year again. Sad (to quote your president).

I only know the ugly style. But I do know that RStan is not going to work with anything less than g+±4.9 (or clang++) in the next version. So, maybe someone knows a different way to get an updated compiler onto Travis?

At least until rstan 3 comes along, using the new “trusty” makes things nice again with TravisCI. Full .travis.yml below. The only change is dist:trusty; probably not needed “quite soon”, since it will become standard. Still testing what this means for C++14

language: r
sudo: false
cache: packages
dist: trusty
latex: false


r-github-packages:
  - jimhester/covr
  - dmenne/breathtestcore

after_success:
  - tar -C .. -xf $PKG_TARBALL
  - Rscript -e 'covr::coveralls(line_exclusions= c("/src/include/models.hpp", "src/*.cpp", "R/zzz.R"))'

To summarize this lengthy thread, hoping that someone finds a better solution:

  • To solve the “constructor” issue, do what Ben suggests a the top of the thread:
    constructors = list(c("SEXP", "SEXP", "SEXP")), fields = character(),
  • If you want to run on TravisCI with the simplified syntax shown above, use dist: trusty; starting from July 17, this is no longer needed, it will be the default.
  • Replace CXX_STD = CXX14 with CXX_STD = CXX11 in Makevars. Currently, this is the settings in Makevars.win anyway. This will produce a lot of warnings about “non-static data member”, but it is not an error as with the compiler that comes in the compiler of default TravisCI precise.
  • Changing to CXX11 is not future-safe, rstan 3.0 requires CXX14, but maybe someone finds better simplified travis.yml

For sure you can find a a more flexible solution using sudo:required and the imperative format; check travis.yml file of package rstanarm. I like the elegant native version.

Feel free to clone https://github.com/dmenne/teststan which is a minimal package using rstan to find a better solution with CXX14. (Hint: I wish the skeleton created by rstan would produce such a package with a sample .stan and travis support)

I also tried r-hub, which is much more flexible when it comes to C++ support. TravisCI is just a bit better integrated into the workflow for me - currently. Don’t be surprised to get an email: teststan 2.16.0: PREPERROR: This is a false-positive bug as Gabor Csardi told me.

I too was able to get rid the errors, and needed to use trusty in order to use recent compilers. My current travis.yml:

In order to use C++14, I used CXX_STD=CXX14 in Makevars and used Dirk’s hack: http://dirk.eddelbuettel.com/blog/2017/06/13/

So add the configure script:

And everything seems to work on Travis as well as locally.

Thanks (also to Dirk), this works great. Maybe @bgoodri could make this solution better exposed somewhere. I have change the thread’s title to make the important part more visible.

Hi, I think I’m running into a similar issue. A code that worked perfectly last week, does not anymore. Any suggestions for someone who is not that computer savy? I’m using windows 10

This issue does not print code from working, so open a different thread to describe the problem you are experiencing.