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

Expand libraries vignette with PACKAGE_types.h #1355

Merged
merged 2 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2025-01-25 Dirk Eddelbuettel <edd@debian.org>

* vignettes/rmd/Rcpp-libraries.Rdm: Add mention of PACKAGE_types.h
* vignettes/rmd/Rcpp.bib: Add AsioHeaders
* inst/bib/Rcpp.bib: Idem

2025-01-18 Ben Bolker <bolker@mcmaster.ca>

* inst/NEWS.Rd: fix trivial typos in NEWS file
Expand Down
8 changes: 8 additions & 0 deletions inst/bib/Rcpp.bib
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ @Manual{CRAN:anytime
url = CRAN # "package=anytime"
}

@Manual{CRAN:AsioHeaders,
title = {'Asio' C++ Header Files},
author = {Dirk Eddelbuettel},
year = {2024},
note = {R package version 1.22.1},
url = CRAN # "package=AsioHeaders"
}

@Manual{CRAN:BH,
title = {BH: Boost C++ Header Files},
author = {Dirk Eddelbuettel and John W. Emerson and Michael
Expand Down
27 changes: 18 additions & 9 deletions vignettes/rmd/Rcpp-libraries.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,24 @@ it.

Given a basic package with C++ support, we can now turn to integrating the external
package. This complexity of this step can, as alluded to earlier, vary from very easy to
very complex. Simple cases include just depending on library headers which can either
be copied to the package, or be provided by another package such as \pkg{BH}
\citep{CRAN:BH}. It may also be a dependency on a fairly standard library available on
most if not all systems. The graphics formats bmp, jpeg or png may be example; text
formats like JSON or XML are another. One difficulty, though, may be that _run-time_
support does not always guarantee _compile-time_ support. In these cases, a `-dev` or
`-devel` package may need to be installed.

In the concrete case of Corels, we
very complex. Simple cases include just depending on library headers which can either be
copied to the package, or be provided by another package such as \pkg{BH} \citep{CRAN:BH}
or \pkg{AsioHeaders} \citep{CRAN:AsioHeaders} or many other examples.

One aspect worth noting is that if you include a type in your function interface it will
also be part of the generated \code{RcppExports.cpp}. In this case adding a file
\code{PACKAGE\_types.h} (where \code{PACKAGE} is to be replaced with the name of your
package) containing the required \code{\#include} statement for the type(s) will permit
compilation; see the 'Rcpp Attributes' vignette for details \citep{CRAN:Rcpp:Attributes}.

It may also be a dependency on a fairly standard library available on most if
not all systems. The graphics formats bmp, jpeg or png may be an example; text
formats like JSON or XML are another. One difficulty, though, may be that
_run-time_ support does not always guarantee _compile-time_ support. In these
cases, a `-dev` or `-devel` package may need to be installed.

Here, we use a third approach and copy files. Discussing the two other means
fully is beyond the scope of this shorter note. So in the concrete case of Corels, we

- copied all existing C++ source and header files over into the `src/` directory;
- renamed all header files from `*.hh` to `*.h` to comply with an R preference;
Expand Down
8 changes: 8 additions & 0 deletions vignettes/rmd/Rcpp.bib
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ @Manual{CRAN:anytime
url = CRAN # "package=anytime"
}

@Manual{CRAN:AsioHeaders,
title = {'Asio' C++ Header Files},
author = {Dirk Eddelbuettel},
year = {2024},
note = {R package version 1.22.1},
url = CRAN # "package=AsioHeaders"
}

@Manual{CRAN:BH,
title = {BH: Boost C++ Header Files},
author = {Dirk Eddelbuettel and John W. Emerson and Michael
Expand Down
Loading