Git Product home page Git Product logo

vscode-rcpp-demo's Introduction

vscode-rcpp-demo

This project is a minimal example of writing and debugging Rcpp in VSCode.

For writing and debugging cpp11 in VSCode, you may go to vscode-cpp11-demo.

Preview

  • Code editing

Code editing

  • Debugging

Debugging

Configuration

Before configuration, install VSCode C/C++ extension.

Code editing

For C/C++ source code editing, only .vscode/c_cpp_properties.json is needed. When the proper paths of included headers are provided, the full-featured C/C++ editing features including auto-completion, hover, definition, type inference, etc. will work. Source code editing does not require that the code is in a package.

In this repo, c_cpp_properties.json is supposed to work with R 4.0 under Ubuntu 16.04 or above. You may need to alter the paths according to your system and C/C++ dependencies of your package.

For example, if your package depends on RcppArmadillo, you may run the following R code to determine the include path:

RcppArmadillo:::CxxFlags()

Then you may add the following path to includePath:

${env:HOME}/R/x86_64-pc-linux-gnu-library/4.0/RcppArmadillo/include

For more code editing features, please visit Edit C++ in Visual Studio Code.

Debugging

Rcpp debugging is easy to configure when the code is in an R package that uses Rcpp like how this repo is organized.

Since R is not a binary executable but a bash script in which required environment variables are setup to start an R session, we also need to setup those environment variables for the debugger to run the R session.

.vscode/debug.R and .vscode/tasks.json are the code to capture those environment variables and to run before debugging. You may need, initially, to run twice in debugging mode before environment variables are properly picked up in .vscode/.env

.vscode/launch.json defines the debugger configuration which in this repo works for R 4.0 under Ubuntu 16.04 or above.

For more debugging features, please visit Debug C++ in Visual Studio Code.

More information

When properly configured, the Rcpp development environment is full-featured as general C/C++ development in VSCode.

Please visit C/C++ for Visual Studio Code for more information.

vscode-rcpp-demo's People

Contributors

renkun-ken avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.