[Rcpp-devel] violates the C++ One Definition Rule ?

Dirk Eddelbuettel edd at debian.org
Mon Jan 24 21:14:27 CET 2022


On 24 January 2022 at 12:55, Toby Hocking wrote:
| Hi Rcpp Devs,
| Does anyone know how to fix this warning in a package with LinkingTo:
| RcppArmadillo? My package plotHMM
| https://www.stats.ox.ac.uk/pub/bdr/LTO/plotHMM.out got this message on CRAN

Worth stressing that this happens under link-time optimziation (lto) which I
am not yet that familiar with.

>From _really briefly_ glancing at your package I see that you include
RcppArmadillo.h in some files (good !) but also include armadillo
directly. It's just a hunch and guess at this point but that may lead to
different 'settings' and #define values.  Maybe try using only RcppArmadillo.h ?

Dirk

| Additional Checks LTO flavor,
| https://www.stats.ox.ac.uk/pub/bdr/LTO/README.txt
| 
| g++ -std=gnu++14 -shared -L/usr/local/lib64 -o plotHMM.so
| RcppExports.o backward.o eln.o forward.o interface.o multiply.o
| pairwise.o transition.o viterbi.o
| /data/gannet/ripley/R/test-4.2/RcppArmadillo/include/armadillo_bits/glue_solve_bones.hpp:84:10:
| warning: type ‘struct opts’ violates the C++ One Definition Rule
| [-Wodr]
|    84 |   struct opts
|       |          ^
| /data/gannet/ripley/R/test-4.2/RcppArmadillo/include/armadillo_bits/glue_solve_bones.hpp:84:10:
| note: a different type is defined in another translation unit
|    84 |   struct opts
|       |          ^
| /data/gannet/ripley/R/test-4.2/RcppArmadillo/include/armadillo_bits/glue_solve_bones.hpp:86:17:
| note: the first difference of corresponding definitions is field
| ‘flags’
|    86 |     const uword flags;
|       |                 ^
| /data/gannet/ripley/R/test-4.2/RcppArmadillo/include/armadillo_bits/glue_solve_bones.hpp:86:17:
| note: a field of same name but different type is defined in another
| translation unit
|    86 |     const uword flags;
|       |                 ^
| _______________________________________________
| Rcpp-devel mailing list
| Rcpp-devel at lists.r-forge.r-project.org
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
-- 
https://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org


More information about the Rcpp-devel mailing list