title: Rcpp and default C++ compiler
body: <p>I have some strange troubles with Rcpp - it uses unpredictable C++ compiler. This question is somewhat similar to <a href="https://stackoverflow.com/questions/32974568/r-package-with-c-c-and-openmp-how-to-make-makevars-file-under-mypackage-sr">this question</a>.<br>
  I'm on OSX, I have 2 complilers - default <code>clang</code> and <code>clang-omp</code> with openmp support.  Also I have following <code>~/.R/Makevars</code> file (where I set up <code>clang-omp</code> as default compiler):  </p>
  
  <blockquote>
    <p>CC=clang-omp<br>
    CXX=clang-omp++<br>
    CFLAGS += -O3 -Wall -pipe -pedantic -std=gnu99<br>
    CXXFLAGS += -O3 -Wall -pipe -Wno-unused -pedantic -fopenmp  </p>
  </blockquote>
  
  <p>The problem is that, the package I'm developing compiles with <code>clang++</code>, not <code>clang-omp++</code>. I also tried (as experiment to lacate issue) to change package <code>src/Makevars</code> and set <code>CXX=clang-omp++</code> and moreover modified <code>$R_HOME/etc/Makeconf</code> <code>CXX</code> entry to <code>CXX = clang-omp++</code>. No luck - it still compiles with <code>clang++</code>. Have no idea why it happens.  </p>
  
  <p>Also here is small reproducible (both from console R and from Rstudio) example (don't know whether it related to issue above).
  Suppose 2 very similar cpp functions:<br>
  1.  </p>
  
  <pre><code>#include &lt;Rcpp.h&gt;
  using namespace Rcpp;
  // [[Rcpp::export]]
  NumericVector timesTwo(NumericVector x) {
    return x * 2;
  }  
  </code></pre>
  
  <p>Call <code>sourceCpp</code> from R:</p>
  
  <pre><code>library(Rcpp)  
  sourceCpp("src/Rcpp_compiler.cpp", verbose = T)
  </code></pre>
  
  <blockquote>
    <p>/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB -o 'sourceCpp_1.so'  'Rcpp_compiler.cpp'<br>
    <strong>clang-omp++</strong> -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include  -I"/Users/dmitryselivanov/Library/R/3.2/library/Rcpp/include" -I"/Users/dmitryselivanov/projects/experiments/src"    -fPIC  -Wall -mtune=core2 -g -O2  -O3 -Wall -pipe -Wno-unused -pedantic -fopenmp -c Rcpp_compiler.cpp -o Rcpp_compiler.o<br>
    <strong>clang-omp++</strong> -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o sourceCpp_1.so Rcpp_compiler.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation</p>
  </blockquote>
  
  <p><strong>Work as expected - uses clang-omp++ and all my flags from <code>~/.R/Makevars</code></strong></p>
  
  <p>2.</p>
  
  <pre><code>#include &lt;Rcpp.h&gt;
  using namespace Rcpp;
  // [[Rcpp::plugins(cpp11)]]
  // [[Rcpp::export]]
  NumericVector timesTwo(NumericVector x) {
    return x * 2;
  }  
  </code></pre>
  
  <blockquote>
    <p>Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB -o 'sourceCpp_2.so'  'Rcpp_compiler.cpp'<br>
    <strong>clang++</strong> -std=c++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include  -I"/Users/dmitryselivanov/Library/R/3.2/library/Rcpp/include" -I"/Users/dmitryselivanov/projects/experiments/src"    -fPIC  -Wall -mtune=core2 -g -O2 -c Rcpp_compiler.cpp -o Rcpp_compiler.o<br>
    <strong>clang++</strong> -std=c++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o sourceCpp_2.so Rcpp_compiler.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation</p>
  </blockquote>
  
  <p><strong>I only added <code>// [[Rcpp::plugins(cpp11)]]</code> and it compiles with <code>clang++</code> instead of <code>clang-omp++</code></strong></p>
  
  <p>Here is my <code>sessionInfo()</code>:</p>
  
  <blockquote>
    <p>R version 3.2.1 (2015-06-18)
    Platform: x86_64-apple-darwin13.4.0 (64-bit)<br>
    Running under: OS X 10.10.5 (Yosemite)<br>
    locale:
    <a href="https://stackoverflow.com/questions/32974568/r-package-with-c-c-and-openmp-how-to-make-makevars-file-under-mypackage-sr">1</a> en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
    attached base packages:<br>
    <a href="https://stackoverflow.com/questions/32974568/r-package-with-c-c-and-openmp-how-to-make-makevars-file-under-mypackage-sr">1</a> stats     graphics  grDevices utils     datasets  methods   base<br>
    other attached packages:
    <a href="https://stackoverflow.com/questions/32974568/r-package-with-c-c-and-openmp-how-to-make-makevars-file-under-mypackage-sr">1</a> Rcpp_0.12.1<br>
    loaded via a namespace (and not attached):
    <a href="https://stackoverflow.com/questions/32974568/r-package-with-c-c-and-openmp-how-to-make-makevars-file-under-mypackage-sr">1</a> tools_3.2.1</p>
  </blockquote>