Repository navigation
Description
System details
RStudio Edition : Desktop
RStudio Version : 1.2.1325
OS Version : macOS 10.14.3
R Version : 3.5.3
Steps to reproduce the problem
Create a new R package containing some compiled code. For simplicity, create a new R package using Rcpp, then execute the following script to initialize that package with the needed infrastructure to reproduce.
dir.create("src/subdir", recursive = TRUE)
writeLines("struct MyClass { int Member; };", "src/subdir/header.h")
writeLines("PKG_CXXFLAGS = -Isubdir", "src/Makevars")
writeLines("#include \"header.h\"\n\nvoid test() { MyClass m; m.Member = 42; }", "src/routine.cpp")
file.edit("src/routine.cpp")The file src/routine.cpp should then be opened. Try making a couple whitespace changes and save the file a couple times to 'wake up' the diagnostics system.
Describe the problem in detail
The diagnostics system flags the use of MyClass even though compilation succeeds.
Describe the behavior you expected
RStudio should be able to understand -Isubdir.
Notes
We do some munging of paths here:
rstudio/src/cpp/session/modules/clang/RCompilationDatabase.cpp
Lines 336 to 350 in f4d3996
| // do path substitutions | |
| BOOST_FOREACH(std::string arg, compileArgs) | |
| { | |
| // do path substitutions | |
| boost::algorithm::replace_first( | |
| arg, | |
| "-I..", | |
| "-I" + srcDir.parent().absolutePath()); | |
| boost::algorithm::replace_first( | |
| arg, | |
| "-I.", | |
| "-I" + srcDir.absolutePath()); | |
| args.push_back(arg); | |
| } |
I think we need to just do the work to normalize / canonicalize paths relative to the source directory in general.

Activity
kevinushey commentedon Mar 15, 2019
Note that, as per the above code, a workaround is to use:
since we correctly parse
.-prefixed paths.stale commentedon Feb 6, 2021
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs, per https://github.com/rstudio/rstudio/wiki/Issue-Grooming. Thank you for your contributions.
stale commentedon Feb 20, 2021
This issue has been automatically closed due to inactivity.