Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linking_to attribute is no longer supported in cpp_source() #193

Closed
paleolimbot opened this issue Jun 26, 2021 · 4 comments · Fixed by #197
Closed

linking_to attribute is no longer supported in cpp_source() #193

paleolimbot opened this issue Jun 26, 2021 · 4 comments · Fixed by #197
Labels
bug an unexpected problem or unintended behavior

Comments

@paleolimbot
Copy link
Contributor

This came from a recent build failure for a pkgdown article that uses the cpp11 knitr engine. I don't think I'm using the attribute incorrectly but it's certainly possible!

Reprex from the cpp_source() example page:

cpp11::cpp_source(
  code = '
#include <cpp11/R.hpp>
#include <RProgress.h>

[[cpp11::linking_to("progress")]]

[[cpp11::register]] void
show_progress() {
  RProgress::RProgress pb("Downloading [:bar] ETA: :eta");

  pb.tick(0);
  for (int i = 0; i < 100; i++) {
    usleep(2.0 / 100 * 1000000);
    pb.tick();
  }
}
')
#> Error: cpp11 attributes must be either `cpp11::register` or `cpp11::init`:
#> - Invalid attribute `cpp11::linking_to` on
#> line 5 in file '/var/folders/bq/2rcjstv90nx1_wrt8d3gqw6m0000gn/T//RtmpH9kS6D/file2d7a258fb142/src/code_2d7a7cbe7751.cpp'.

Would it make sense to add linking_to to the list of allowed decorations here?

bad_decor <- !decorations$decoration %in% c("cpp11::register", "cpp11::init")

@paleolimbot
Copy link
Contributor Author

I think this is also erroring for any C++ signature that contains a regular C++ attribute:

> devtools::load_all(".")
ℹ Loading wk
Error: cpp11 attributes must be either `cpp11::register` or `cpp11::init`:
- Invalid attribute `noreturn` on
line 283 in file '/Users/dewey/Desktop/cran/wk/src/handle-wkt.cpp'.
- Invalid attribute `noreturn` on
line 287 in file '/Users/dewey/Desktop/cran/wk/src/handle-wkt.cpp'.
- Invalid attribute `noreturn` on
line 291 in file '/Users/dewey/Desktop/cran/wk/src/handle-wkt.cpp'.

@jimhester jimhester added the bug an unexpected problem or unintended behavior label Jun 28, 2021
@jimhester
Copy link
Member

jimhester commented Jun 28, 2021

@sbearrows we will need to fix the changes in #180 to include cpp11::linking_to (I forgot about it when we discussed it) and to ignore any attribute that doesn't have a cpp11:: prefix.

We should also add some tests to cover the issues that @paleolimbot has kindly reported here.

@sbearrows
Copy link
Contributor

I can start working on this next!

@paleolimbot
Copy link
Contributor Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants