Zeekg

Zeekg

Setting up C++ environment in VScode (Mac)

I remember the first programming language I learned was C, and the first editor I used was the C++ editor, which is Code::Blocks.

During that time, I used this editor to practice C++ and learn algorithms.

But later on, I started using other editors after getting into Java and JavaScript.

Until now, the editor I use the most is still VScode.

There was a time when I wanted to write C++ in VScode, but there were still many compatibility issues at that time, so it didn't work out (maybe because I was using Windows).

I also tried using Clion, but I always felt unsatisfied.

This time, I tried setting up the C++ environment in VScode again, and unexpectedly, it went quite smoothly. Haha.

Prerequisites#

  • Install VScode
  • Install clang, it's easy to install this thing on Mac, and there are also many good resources online.

VScode Extensions#

Let me list the extensions I installed.

  • C/C++
  • Code Runner

Here are some screenshots:

image

image

Yes, basically you can start using it at this point.

As for how to run and debug, you can refer to this:

image

It will automatically help you build the tasks.json file, so you can continue developing in C++.

Now it's so convenient, it feels like I was deceived before. 😅

Others#

Running C++ 11#

The Code Runner extension does not support running C++ by default.

But it's actually just a matter of changing the configuration.

In the Code Runner configuration, find the Executor Map:

image

Then find the line for C++ and add -std=c++ to the command:

image

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.