Up and running in C++

20161016

You just read “A Tour of C++” by Stroustrup and realized C++ may actually be a nice language. Now you just want a simple dev environment with code completion, on-the-fly inline error reporting and jump to definition. This guide is for you.

We’re going to use Buck as our build tool, Visual Studio Code as our text editor. We assume macOS, but it should be similar on Linux, and maybe Windows.

// helloworld.cpp
#include <iostream>

int main(int argc, char** argv) {
  std::cout << "hello world!" << std::endl;
  return 0;
}

# BUCK
cxx_binary(
    name = 'helloworld',
    srcs = glob(['*.cpp']),
    compiler_flags = ['-std=c++1y'],
)

brew update && brew tap facebook/fb && brew install buck
buck build :helloworld
{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "0.1.0",
    "command": "buck",
    "isShellCommand": true,
    "args": ["run", ":helloworld"],
    "showOutput": "always"
}
Domo-kun!