Skip to content

C++ diagnostics don't understand '-Ipath/to/include' #4457

Closed

Description

@kevinushey

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.

Screen Shot 2019-03-15 at 11 05 35 AM

Describe the behavior you expected

RStudio should be able to understand -Isubdir.

Notes

We do some munging of paths here:

// 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

  1. kevinushey commented on Mar 15, 2019

    @kevinushey
    CollaboratorAuthor

    Note that, as per the above code, a workaround is to use:

    PKG_CXXFLAGS = -I./subdir
    

    since we correctly parse .-prefixed paths.

  2. added this to the v1.3 milestone on Mar 15, 2019
  3. removed this from the v1.3 milestone on Dec 2, 2019
  4. self-assigned this
    on Dec 2, 2019
  5. stale commented on Feb 6, 2021

    @stale

    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.

  6. added
    stale
    on Feb 6, 2021
  7. stale commented on Feb 20, 2021

    @stale

    This issue has been automatically closed due to inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugc++diagnosticspackage devstale

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions