Skip to content

Commit b8ddc0f

Browse files
authored
Merge pull request #80 from eecs280staff/vscode-codellb
VS Code / CodeLLDB
2 parents d34f5ff + 36418c6 commit b8ddc0f

File tree

4 files changed

+47
-44
lines changed

4 files changed

+47
-44
lines changed

docs/images/vscode031b.png

146 KB
Loading

docs/images/vscode065.png

-62.6 KB
Binary file not shown.

docs/images/vscode160.png

238 KB
Loading

docs/setup_vscode.md

+47-44
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ $ rm -rf p1-stats # Delete
3232
```
3333

3434
## Install
35-
Choose your platform below.
35+
Choose your platform below. Also make sure to install extensions.
3636

3737
### Linux
3838
Install the .deb package from the web [https://code.visualstudio.com/docs/setup/linux](https://code.visualstudio.com/docs/setup/linux).
@@ -71,70 +71,55 @@ $ code --version
7171
x64
7272
```
7373

74-
#### WSL remote mode
75-
76-
Use VS Code's [remote mode](https://code.visualstudio.com/docs/remote/wsl) to connect the VS Code graphical user interface (GUI) running on Windows to the Linux environment and tools like `g++` running on WSL.
77-
78-
WSL Remote Mode connects VS Code to a remote instance of a VS Code server running elsewhere. When you launch VS Code from the WSL terminal, a VS Code server is started within WSL and the VS Code UI running on Windows connects to that server.
79-
80-
<img src="images/vscode065.png" width="512px">
81-
82-
Install the [WSL extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl). It's OK if you have other extensions installed.
83-
```console
84-
$ code --install-extension ms-vscode-remote.remote-wsl
85-
$ code --list-extensions
86-
ms-vscode-remote.remote-wsl
87-
```
88-
89-
After the extension is installed, quit VS Code and start it again.
90-
91-
You'll know that VS Code is running in remote mode when you see the remote mode indicator in the bottom left corner.
92-
93-
<img src="images/vscode068.png" width="768px">
94-
95-
<div class="primer-spec-callout warning" markdown="1">
96-
**Pitfall:** If you accidentally open VS Code from Windows mode, click on the green icon in the lower left hand corner and then select "Reopen Folder in WSL".
97-
98-
<img src="images/vscode070.png" width="720">
99-
</div>
100-
10174
### Extensions
10275
Make sure VS Code is installed correctly by checking the version. You need version 1.52.1 or higher.
10376
```console
10477
$ code --version
10578
1.52.1
10679
```
10780

108-
Install the Microsoft [C/C++ extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools).
81+
Install the Microsoft [C/C++ extensions](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools).
10982
```console
11083
$ code --install-extension ms-vscode.cpptools
11184
$ code --install-extension ms-vscode.cpptools-extension-pack
11285
```
11386

114-
<div class="primer-spec-callout warning" markdown="1">
115-
Verify that the cpptools extensions installed. It's OK if you have other extensions installed.
116-
```consle
87+
Verify that the extensions are installed. It's OK if you have other extensions installed.
88+
```console
11789
$ code --list-extensions
11890
ms-vscode.cpptools
11991
ms-vscode.cpptools-extension-pack
12092
```
121-
</div>
12293

123-
<div class="primer-spec-callout warning" markdown="1">
124-
Verify that the clangd or CodeLLDB extensions are *not* installed. The clangd extension provides C/C++ intellisense which conflicts with the Microsoft C/C++ extension. The CodeLLDB extension provides C/C++ debugging support which causes confusion with the Microsoft C/C++ extension.
125-
```consle
94+
#### macOS
95+
Install the [CodeLLDB extension](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb).
96+
```console
97+
$ code --install-extension vadimcn.vscode-lldb
98+
```
99+
100+
Verify that the extension is installed. It's OK if you have other extensions installed.
101+
```console
126102
$ code --list-extensions
127-
llvm-vs-code-extensions.vscode-clangd # REMOVE ME
128-
vadimcn.vscode-lldb # REMOVE ME
103+
vadimcn.vscode-lldb
129104
```
130105

131-
Uninstall them if necessary.
106+
#### Windows
107+
Install the [WSL extension](https://code.visualstudio.com/docs/remote/wsl) to develop with Linux-based utilities like the `g++` compiler.
132108
```console
133-
$ code --uninstall-extension llvm-vs-code-extensions.vscode-clangd
134-
$ code --uninstall-extension vadimcn.vscode-lldb
109+
$ code --install-extension ms-vscode-remote.remote-wsl
135110
```
136-
</div>
137111

112+
Quit VS Code and start it again.
113+
114+
Verify that the extension is installed. It's OK if you have other extensions installed.
115+
```console
116+
$ code --list-extensions
117+
ms-vscode-remote.remote-wsl
118+
```
119+
120+
You'll know that VS Code is running in remote mode when you see the remote mode indicator in the bottom left corner.
121+
122+
<img src="images/vscode069.png" width="768px">
138123

139124
## Create a project
140125
To create a VS Code project, create a folder (directory). There are many ways to create folders: Finder AKA File Explorer, VS Code interface, VS Code integrated terminal, and the system terminal. We'll use the system terminal and call our example project `p1-stats`.
@@ -324,11 +309,15 @@ Click "create a launch.json file".
324309

325310
<img src="images/vscode031.png" width="768px" />
326311

327-
Click "Add Configuration".
312+
**macOS:** Select LLDB.
313+
314+
<img src="images/vscode031b.png" width="768px" />
315+
316+
You may need to click "Add Configuration".
328317

329318
<img src="images/vscode032.png" width="768px" />
330319

331-
Select a "Launch" configuration. This will create a default `launch.json` ([Microsoft Reference](https://code.visualstudio.com/docs/cpp/launch-json-reference)).
320+
You may need to select a "Launch" configuration. This will create a default `launch.json` ([Microsoft Reference](https://code.visualstudio.com/docs/cpp/launch-json-reference)).
332321
- macOS: "C/C++ (lldb) Launch"
333322
- WSL orLinux: "C/C++ (gdb) Launch"
334323

@@ -576,6 +565,11 @@ Press "Continue" to run the program to the next breakpoint, or the end, whicheve
576565
## Troubleshooting
577566
This section is for common problems and solutions.
578567

568+
### Compile and run
569+
If you have trouble with the [compile and run](#compile-and-run) section, a good first step is to delete your `launch.json` and try the [compile and run](#compile-and-run) section again.
570+
571+
<img src="images/vscode160.png" width="768px" />
572+
579573
### Intellisense C++ Standard
580574
Intellisense is the feature that indicates compiler errors with red squiggly lines and suggests code completions. If the C++ standard is out-of-date, you'll see squiggles where you shouldn't.
581575

@@ -601,6 +595,15 @@ Modify the `cStandard` and `cppStandard` settings in `c_cpp_properties.json`. D
601595
```
602596
{: data-title="c_cpp_properties.json" data-highlight="5-6" }
603597

598+
### C/C++ extension alternatives
599+
There are multiple options for C/C++ extensions.
600+
601+
[Microsoft C/C++ extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools) provides debugging support and intellisense on Windows, Linux and macOS. At the time of this writing (January 2023) debug support has a [bug on macOS](https://github.com/microsoft/vscode-cpptools/issues/7240).
602+
603+
[CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb) provides debugging support for those using the LLVM compiler. Apple's compiler on macOS is based on LLVM.
604+
605+
[clangd](https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd) provides intellisense and requires the `clangd` language server, which is related to the LLVM compiler. We do not recommend installing the `clangd` extension with the Microsoft C/C++ extension because multiple intellisense providers can produce confusing results.
606+
604607

605608
## Acknowledgments
606609
Original document written by Andrew DeOrio [email protected].

0 commit comments

Comments
 (0)