如何确保 win-builder 使用 c++11 构建我的包?

How to make sure win-builder builds my package with c++11?

我正在尝试制作我的包裹(code available here) pass win-builder tests so I can upload to cran. The package relies heavily in Rcpp and I use some things that require C++11 standard. But the win-builder test results 不断显示如下警告:

warning: delegating constructors only available with -std=c++11 or -std=gnu++11
warning: extended initializer lists only available with -std=c++11 or -std=gnu++11

我尝试使用 Rcpp.package.skeleton() 示例包进行最小测试,添加了一些扩展的初始化列表使用,以及一个仅包含一行的 Makevars 文件:

CXX_STD = CXX11

但最小测试工作正常。您可以在最小测试的 win-builder 测试结果中看到它正在使用 -std=gnu++11 进行编译,而我的包在没有该选项的情况下进行编译:

最小测试:

*** arch - i386
d:/Compiler/gcc-4.9.3/mingw_32/bin/g++  -std=gnu++11 -I"D:/RCompile/recent/R/include" -DNDEBUG  -I"d:/RCompile/CRANpkg/lib/3.5/Rcpp/include"   -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall  -mtune=core2 -c RcppExports.cpp -o RcppExports.o

我的包裹:

*** arch - i386
d:/Compiler/gcc-4.9.3/mingw_32/bin/g++  -I"D:/RCompile/recent/R/include" -DNDEBUG  -I"d:/RCompile/CRANpkg/lib/3.5/Rcpp/include"   -I"d:/Compiler/gcc-4.9.3/local330/include"     -pedantic -O2 -Wall  -mtune=core2 -c Individual.cpp -o Individual.o

为什么用不同的选项编译它们?我正在使用完全相同的 Makevars 文件。为了以防万一,我的 DESCRIPTION:

上有这些行
Imports:
    Rcpp (>= 0.12.14),
    Matrix,
    grid,
    animation
LinkingTo: Rcpp
Suggests:
    knitr,
    rmarkdown
Depends:
    R (>= 3.1.0)
License: GPL-2
LazyData: true
RoxygenNote: 6.0.1
URL: https://github.com/Lobz/facilitation
VignetteBuilder: knitr

编辑:我将上面的内容复制到最小测试包的 DESCRIPTION 文件中,使它们更相似,并且最小测试文件仍然可以使用 -std=gnu++11.

正确编译

注意:我通过 devtools::build_win().

将软件包上传到 win-builder

尝试添加 DESCRIPTION

SystemRequirements: C++11

这避免了必须为不同平台指定自定义 Makevars 的需要(例如 Makevars 用于 Unix + Solaris + macOS,Makevars.win 用于 windows)。

然而,正如@DirkEddelbuettel 所说,Windows 存在 C++11 支持;但是,C++11gcc-4.9.3 实现的完整性在库方面存在问题