Search code examples
clangrstudiorcpp

Why cpp diagnostics and code completion stopped working in RStudio?


I have been using Rcpp and RcppArmadillo for quite some time now and I love it! The feasibility of my research projects was boosted thanks to much faster computation performed using cpp code in R!

A super useful functionality of Rcpp is script diagnostics and code completion understood as in this doc: https://support.rstudio.com/hc/en-us/articles/200486088-Using-Rcpp-with-the-RStudio-IDE

It was working well in my RStudio until it stopped. Now whatever I do, I can't bring this functionality back. And I'm not that happy about it.

Do you have a solution to that? I could not find anything really here. I would greatly appreciate your help.

I work on mac with the latest system updates. I have up-to-date versions of RStudio, R, XCode, and freshly reinstalled Rcpp and RcppArmadillo packages. The compiler and the codes work perfectly fine. Just not the extra RStudio functionality with cpp. I'd be happy to provide more info about my setup if required.


Solution

  • If you execute .rs.setClangDiagnostics(2) from the R console before you interact w/ C++ you should see some detailed error messages in the console indicating what the source of the problem might be. I am a bit out of practice interpreting these diagnostics but @kevin-ushey or someone else on the RStudio team should be able to take it from there.