Skip to content

Commit 6ab92eb

Browse files
committed
Add note on using inline keyword from shared header files
1 parent 8fd21a3 commit 6ab92eb

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

ChangeLog

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
2015-02-19 JJ Allaire <[email protected]>
2+
3+
* vignettes/Rcpp-attributes.Rnw: Add note on using inline
4+
keyword from shared header files.
5+
16
2015-02-17 JJ Allaire <[email protected]>
27

38
* vignettes/Rcpp-attributes.Rnw: Update attributes vignette
4-
with docs on new features,
9+
with docs on new features.
510

611
2015-02-14 JJ Allaire <[email protected]>
712

vignettes/Rcpp-attributes.Rnw

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ shared functions, classes, enums, etc. For example:
428428
#ifndef __UTILITIES__
429429
#define __UTILITIES__
430430
431-
double timesTwo(double x) {
431+
inline double timesTwo(double x) {
432432
return x * 2;
433433
}
434434
@@ -440,6 +440,8 @@ that code is not included more than once in a source file. You should
440440
use an include guard and be sure to pick a unique name for the corresponding
441441
\texttt{\#define}.
442442

443+
Also note the use of the \code{inline} keyword preceding the function. This isn't necessary for \code{sourceCpp} however if you are working on an R package then it's important to ensure that there are not multiple definitions of functions included from header files. Classes fully defined in header files automatically have inline semantics so don't require this treatment.
444+
443445
To use this code in a source file you'd just include
444446
it based on it's relative path (being sure to use \texttt{"} as the
445447
delimiter to indicate a local file reference). For example:

0 commit comments

Comments
 (0)