Skip to content

Commit 59ee609

Browse files
hadleyDavisVaughan
andauthored
Tweak setup instructions (#342)
* Tweak setup instructions * Fixup some typos --------- Co-authored-by: Davis Vaughan <[email protected]>
1 parent be22d58 commit 59ee609

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

vignettes/cpp11.Rmd

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,27 +1102,27 @@ There are several benefits of moving code from a stand-alone C++ source file to
11021102

11031103
1. Packages provide additional infrastructure for testing, documentation, and consistency.
11041104

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.
11071106

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
11091112
LinkingTo: cpp11
11101113
```
11111114
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`)
11131116

1114-
```
1117+
```R
11151118
#' @useDynLib pkgname, .registration = TRUE
11161119
```
11171120

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.
11211122

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.
11231124
This function scans the C++ files for `[[cpp11::register]]` attributes and generates the binding code required to make the functions available in R.
11241125
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.
11261126

11271127
## Learning more {#more}
11281128

0 commit comments

Comments
 (0)