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: README.md
+18-5Lines changed: 18 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,24 +24,37 @@ After discussing some [pull requests](https://github.com/r-lib/cpp11/pulls/pacha
24
24
-[x] Provide flexibility with data types (e.g., cpp4r's `as_integers()` and `as_doubles()` accept logical inputs while cpp11's do not).
25
25
-[x] Some internal optimizations for better speed (e.g., https://github.com/r-lib/cpp11/pull/463 and https://github.com/r-lib/cpp11/pull/430).
26
26
27
+
## Getting started
28
+
29
+
Check the [documentation](https://cpp4r.org/) to get started using cpp4r in your scripts, particularly if you are new to C++ programming.
30
+
27
31
## Using cpp4r in a package
28
32
33
+
Create a new package with `cpp4r::pkg_template("~/path/to/mypkg")` and then edit the generated files.
34
+
29
35
To add cpp4r to an existing package, put your C++ files in the `src/` directory and add the following to your DESCRIPTION file:
30
36
31
37
```
32
38
LinkingTo: cpp4r
33
39
```
34
40
41
+
Then add a roxygen header, for example, to `R/mypkg-package.R`:
42
+
43
+
```r
44
+
#' @useDynLib mypkg, .registration = TRUE
45
+
#' @keywords internal
46
+
"_PACKAGE"
47
+
```
48
+
35
49
Then decorate C++ functions you want to expose to R with `[[cpp4r::register]]`.
36
50
37
-
cpp4r is a header only library with no hard dependencies and does not use a shared library, so it is straightforward and reliable to use in packages without fear of compile-time and run-time mismatches.
51
+
cpp4r is a header only library with no hard dependencies and does not use a shared library. It is straightforward and reliable to use in packages without fear of compile-time and run-time mismatches.
38
52
39
-
Alternatively, you can [vendor](https://cpp4r.org/articles/motivations.html#vendoring) the current installed version of cpp4r headers into your package with `cpp4r::vendor_cpp4r()`.
40
-
This ensures the headers will remain unchanged until you explicitly update them.
53
+
## Vendoring
41
54
42
-
## Getting started
55
+
You can [vendor](https://cpp4r.org/articles/motivations.html#vendoring) the current installed version of cpp4r headers into your package with `cpp4r::vendor_cpp4r()`.
43
56
44
-
See [vignette("cpp4r")](https://cpp4r.org/articles/cpp4r.html) to get started using cpp4r in your scripts, particularly if you are new to C++ programming.
57
+
This ensures the headers will remain unchanged until you explicitly update them.
0 commit comments