Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6351429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:00:21+00:00 2026-05-24T22:00:21+00:00

I want to set -std=c++0x , using Rcpp with inline. I saw R: C++

  • 0

I want to set -std=c++0x, using Rcpp with inline.

I saw R: C++ Optimization flag when using the inline package but don’t want to make a system-wide change, so I was trying option 2 in Dirk’s answer.

I tried:

settings=getPlugin("Rcpp")
settings$Makevars[length(settings$Makevars)+1] = "CXXFLAGS = $(CXXFLAGS) -std=c++0x"
fun=cxxfunction(signature(x_ ="numeric"),src,plugin="Rcpp",settings=settings,verbose=2);

But the verbose output shows it is ignoring that. I also tried with CFLAGS, and without including existing value, but no effect.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T22:00:22+00:00Added an answer on May 24, 2026 at 10:00 pm

    After some source code study, and a hint from Dirk Eddelbuettel, I’ve worked this out:

    settings$env$PKG_CXXFLAGS='-std=c++0x'
    

    You can set PKG_CPPFLAGS the same way.

    Here is a complete and more robust example:

    library(inline)
    
    src='
    using namespace Rcpp;
    std::vector<const char*> test={"Hello","World","!!!"};
    return wrap(test);
    '
    
    settings=getPlugin("Rcpp")
    settings$env$PKG_CXXFLAGS=paste('-std=c++0x',settings$env$PKG_CXXFLAGS,sep=' ')
    fun=cxxfunction(signature(),src,plugin="Rcpp",settings=settings)
    
    Sys.unsetenv('PKG_CXXFLAGS')
    
    print(fun())
    

    The paste() makes sure if there were any settings already in the plugin then they are preserved.

    The unsetenv() is something cxxfunction should already be doing (IMHO). Currently it will add variables to the environment, but not remove them after. So, without the unsetenv() call, if you later ran cxxfunction again, but with all defaults, any CXXFLAGS you had earlier set would get used. This might not matter, or it might give surprising results. (Imagine if your were using PKG_CXXFLAGS to set -Wall -Werror for your own code, but later code links to a 3rd party library and refuses to compile with those options.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to hold a bunch of const char pointers into an std::set container
I want set Listbox background to transparent but not working Is there any idea?
I want to set a breakpoint on the __DoPostBack method, but it's a pain
I want to set some attributes just before the object is serialized, but as
I want to reverse the contents of a std::set (Not just iterating theough it
I'm adding two different elements to both std::list and std::set and I want the
So I've got an array (0 - n), holding values that I want std::set
I have a std::set<std::string> and I want to know the exact position of the
#include <iostream> #include <set> #include <algorithm> #include <boost/lambda/lambda.hpp> #include <boost/bind.hpp> using namespace std; using
I want set interfaceOrientation in one UIView as LandscapeLeft and Portrait in other UIView.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.