You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: vignettes/cpp11.Rmd
+10-10Lines changed: 10 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -1102,27 +1102,27 @@ There are several benefits of moving code from a stand-alone C++ source file to
1102
1102
1103
1103
1. Packages provide additional infrastructure for testing, documentation, and consistency.
1104
1104
1105
-
To add `cpp11` to an existing package first put your C++ files in the `src/` directory of your package.
1106
-
Then add the following to your `DESCRIPTION` file:
1105
+
To add `cpp11` to an existing package first put your C++ files in the `src/` directory of your package.
1107
1106
1108
-
```
1107
+
Then the easiest way to configure everything is to call `usethis::use_cpp11()`. Alternatively:
1108
+
1109
+
* Add this to your `DESCRIPTION` file:
1110
+
1111
+
```yaml
1109
1112
LinkingTo: cpp11
1110
1113
```
1111
1114
1112
-
and add the following [roxygen](https://roxygen2.r-lib.org/) directive somewhere in your package's R files. (A common location is `R/pkgname-package.R`)
1115
+
* And add the following [roxygen](https://roxygen2.r-lib.org/) directive somewhere in your package's R files. (A common location is `R/pkgname-package.R`)
1113
1116
1114
-
```
1117
+
```R
1115
1118
#' @useDynLib pkgname, .registration = TRUE
1116
1119
```
1117
1120
1118
-
You'll then need to run [`devtools::document()`](https://devtools.r-lib.org/reference/document.html) to update your `NAMESPACE` file to include the `useDynLib` statement.
1119
-
1120
-
The easiest way to set this up is to call `usethis::use_cpp11()`, which will do the above steps for your automatically.
1121
+
* You'll then need to run [`devtools::document()`](https://devtools.r-lib.org/reference/document.html) to update your `NAMESPACE` file to include the `useDynLib` statement.
1121
1122
1122
-
Before building the package, you'll need to run `cpp11::cpp_register()`.
1123
+
If you don't use `devtools::load_all()`, you'll also need to run `cpp11::cpp_register()` before building the package.
1123
1124
This function scans the C++ files for `[[cpp11::register]]` attributes and generates the binding code required to make the functions available in R.
1124
1125
Re-run `cpp11::cpp_register()` whenever functions are added, removed, or have their signatures changed.
1125
-
If you are using `devtools` to develop your package this is done automatically by the pkgbuild package when your package has `LinkingTo: cpp11` in its DESCRIPTION file.
0 commit comments