Rcpp in Rstudio 1.2 on Windows 10: diagnostics not working

Greetings: I've tried upgrading to RStudio 1.2 a couple of times, just now with 1.2.5001. On both occasions, Rcpp diagnostics stop working (see screenshot linked below). When I revert to RStudio 1.1, everything's fine again.

From googlings, nobody else appears to be having the same problem which makes me suspect it's something on my machine. I'm not a C++ expert (Java / R is my usual thing) but it's looking like it's not loading the Rcpp namespace (the diagnostic problems are with e.g. NumericVector, Rcout etc). I've updated everything else (R and Rcpp), still no joy.

Is anyone else having the same difficulty / has any thoughts on a fix? For now, back to 1.1....!

Or here's a link to that screenshot if that doesn't work.

Some questions:

  1. Do you have a project open?

  2. If so, are you editing a C++ file within that project? Or a C++ file within a separate folder?

  3. If you have a project open, what kind of project is it? Is it an R package project? Does it contain a custom src/Makevars file?

  4. Do you have a custom ~/.R/Makevars file?

  5. Do you have Rtools installed? If so, where?

Hi Kevin,

Yes: project open, C++ file being edited within project folder. It's a standard R project, not a package project or anything else.

I don't have a custom ~/.R/Makevars file. Don't know what that is.

Rtools is installed in the C drive root directory.

Any thoughts?

Can you try running:

.rs.setClangDiagnostics(2)

and then attempt to Source that file? You should get a lot of diagnostic output printed to the console -- would you be able to copy that over?

clang version 5.0.2 (tags/RELEASE_502/final)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir:
ignoring nonexistent directory "lib\clang\5.0.2\include"
ignoring nonexistent directory "C:/Program Files/Microsoft Visual Studio 10.0/VC/include"
ignoring nonexistent directory "C:/Program Files/Microsoft Visual Studio 9.0/VC/include"
ignoring nonexistent directory "C:/Program Files/Microsoft Visual Studio 9.0/VC/PlatformSDK/Include"
ignoring nonexistent directory "C:/Program Files/Microsoft Visual Studio 8/VC/include"
ignoring nonexistent directory "C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/Include"
#include "..." search starts here:
#include <...> search starts here:
C:/Program Files/RStudio/resources/libclang/builtin-headers/5.0.2
C:/Program Files/RStudio/resources/libclang/builtin-headers/libc++/5.0.2
C:/PROGRA~1/R/R-36~1.1/include
C:/Users/admin/Dropbox/RPackages/Rcpp/include
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM
End of search list.
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:8:46: error: call to 'floor' is ambiguous
C:/Program Files\RStudio\resources\libclang\builtin-headers\libc++\5.0.2\math.h:866:46: note: candidate function
C:/Program Files\RStudio\resources\libclang\builtin-headers\libc++\5.0.2\math.h:867:46: note: candidate function
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:16:24: error: member reference base type 'Rcpp::NumericVector' (aka 'int') is not a structure or union
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:16:35: error: member reference base type 'Rcpp::NumericVector' (aka 'int') is not a structure or union
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:30:3: error: use of undeclared identifier 'Rcout'
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:30:18: error: use of undeclared identifier 'rand'
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:30:33: error: use of undeclared identifier 'RAND_MAX'
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:40:26: error: member reference base type 'Rcpp::NumericVector' (aka 'int') is not a structure or union
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:41:17: error: subscripted value is not an array, pointer, or vector
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:45:26: error: member reference base type 'Rcpp::NumericVector' (aka 'int') is not a structure or union
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:46:17: error: subscripted value is not an array, pointer, or vector
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:52:26: error: member reference base type 'Rcpp::NumericVector' (aka 'int') is not a structure or union
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:57:25: error: subscripted value is not an array, pointer, or vector
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:57:42: error: subscripted value is not an array, pointer, or vector
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:89:3: error: use of undeclared identifier 'Rcout'
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:105:10: error: use of undeclared identifier 'rand'
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:117:23: error: use of undeclared identifier 'rand'
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:117:44: error: member reference base type 'Rcpp::NumericVector' (aka 'int') is not a structure or union
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:118:23: error: use of undeclared identifier 'rand'
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:118:44: error: member reference base type 'Rcpp::NumericVector' (aka 'int') is not a structure or union
fatal error: too many errors emitted, stopping now [-ferror-limit=]
TOTAL MEMORY: 54 mb (simfunctions.cpp)
PERFORMANCE 794 ms (simfunctions.cpp)
CLANG INDEXING: C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp
CLANG REMOVE INDEX: C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp
(Creating new index)
clang version 5.0.2 (tags/RELEASE_502/final)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir:
ignoring nonexistent directory "lib\clang\5.0.2\include"
ignoring nonexistent directory "C:/Program Files/Microsoft Visual Studio 10.0/VC/include"
ignoring nonexistent directory "C:/Program Files/Microsoft Visual Studio 9.0/VC/include"
ignoring nonexistent directory "C:/Program Files/Microsoft Visual Studio 9.0/VC/PlatformSDK/Include"
ignoring nonexistent directory "C:/Program Files/Microsoft Visual Studio 8/VC/include"
ignoring nonexistent directory "C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/Include"
#include "..." search starts here:
#include <...> search starts here:
C:/Program Files/RStudio/resources/libclang/builtin-headers/5.0.2
C:/Program Files/RStudio/resources/libclang/builtin-headers/libc++/5.0.2
C:/PROGRA~1/R/R-36~1.1/include
C:/Users/admin/Dropbox/RPackages/Rcpp/include
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM
End of search list.
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:8:46: error: call to 'floor' is ambiguous
C:/Program Files\RStudio\resources\libclang\builtin-headers\libc++\5.0.2\math.h:866:46: note: candidate function
C:/Program Files\RStudio\resources\libclang\builtin-headers\libc++\5.0.2\math.h:867:46: note: candidate function
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:16:24: error: member reference base type 'Rcpp::NumericVector' (aka 'int') is not a structure or union
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:16:35: error: member reference base type 'Rcpp::NumericVector' (aka 'int') is not a structure or union
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:30:3: error: use of undeclared identifier 'Rcout'
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:30:18: error: use of undeclared identifier 'rand'
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:30:33: error: use of undeclared identifier 'RAND_MAX'
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:40:26: error: member reference base type 'Rcpp::NumericVector' (aka 'int') is not a structure or union
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:41:17: error: subscripted value is not an array, pointer, or vector
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:45:26: error: member reference base type 'Rcpp::NumericVector' (aka 'int') is not a structure or union
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:46:17: error: subscripted value is not an array, pointer, or vector
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:52:26: error: member reference base type 'Rcpp::NumericVector' (aka 'int') is not a structure or union
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:57:25: error: subscripted value is not an array, pointer, or vector
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:57:42: error: subscripted value is not an array, pointer, or vector
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:89:3: error: use of undeclared identifier 'Rcout'
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:105:10: error: use of undeclared identifier 'rand'
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:117:23: error: use of undeclared identifier 'rand'
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:117:44: error: member reference base type 'Rcpp::NumericVector' (aka 'int') is not a structure or union
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:118:23: error: use of undeclared identifier 'rand'
C:/Users/admin/Dropbox/SheffieldMethodsInstitute/SocialFrontiers/SIM/simfunctions.cpp:118:44: error: member reference base type 'Rcpp::NumericVector' (aka 'int') is not a structure or union
fatal error: too many errors emitted, stopping now [-ferror-limit=]
TOTAL MEMORY: 54 mb (simfunctions.cpp)
PERFORMANCE 864 ms (simfunctions.cpp)

p.s. I get that output when I save the cpp file, not source it...? It will source/compile fine, by the way. The errors it's suggesting are there on save don't cause actual compile problems.

p.p.s. thank you so much for helping!

Sorry for taking so long to respond.

It looks like RStudio is not finding the Rtools headers, for some reason. For reference, where is Rtools installed on your machine?

It appears I may be having a similar problem. In response to the questions asked earlier in the thread:

  1. I do have a project open.
  2. Editing within the open project.
  3. It is an Rproj file (are there other kinds of projects?) that was generated using an existing folder.
  4. No. I don't even know what that is.
  5. Yes. C:/Rtools. I'm using 3.5

Hi Kevin - Rtools is in the root folder, just at C:

I've currently gone back to 1.1. With the same Rtools in the same location, same everything else, C++ diagnostics work fine.

1.2 was doing a few other things that made me switch back too (doesn't work with copy/pasting file paths from copying files in explore, was doing an odd run-whole-script thing when attempting to run a single line, but only randomly. Both problems not present in 1.1.)

Guess I'll try 1.2 again in a few months, see if anything has changed?

Could you also give the latest daily build a try, and let me know if things are fixed there?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.