![]() Set a breakpoint on the first line of the main() function by clicking slightly to the left of its line number you should see a red dot appear. Like most IDE debuggers, it has a menu showing your currently active variables, watched variables, call stack, and currently active breakpoints. ![]() You should see an icon on the left sidebar that looks like a play button with a bug on it – this is the debugger menu, go ahead and open it. We provide some debugging configurations for you that can be installed through terminal.Įxecute the following commands one-by-one to install our recommended configuration files: In order to debug C++ code, we need to give VSCode some extra information about how we want to debug. It should be the only extension that appears. ![]() Go back to the Extensions Marketplace to find and install the “CodeLLDB” extension made by Vadim Chugunov. If you aren’t, please read through this tutorial (it’s in Python, but the same core principles apply). You should be familiar with an IDE debugger from your previous programming class (CSE 231 or an equivalent prerequisite). It is incredibly helpful once you get the hang of it. Note: I strongly recommend you setup the debugger now, and use it to your advantage throughout this course. We’ll be talking more about the compilation command and what you can do with it, though, so it’s best to be familiar with both. If you setup the debugger (the section below), you can compile and run in a single mouse-click. Keep them in your notes or memorize them (you’ll likely have them memorized within a few days of practice). You will be typing those two commands hundreds of times in this course. It’s important to note that you must compile your program and run a.out every time you want to test your code. Type/copy-paste the following code into your helloworld.cpp file:Ĭongratulations! You just made your first program in C++. Go back to the integrated file explorer after installing the extension and create a file named “helloworld.cpp”. Go ahead and Install the extension once you find it. Search for “C/C++” and you should find an extension of the same name, developed by Microsoft: You can right-click inside the panel for many of the options you’d typically have in Finder:Ĭlick the icon of four squares on the left sidebar to bring up the Extensions Marketplace. The top of the sidebar should now display the name of the folder you opened, which is presumably empty (unless you have files there). ![]() Click on this icon to open the integrated file explorer as shown here:Ĭlick the “Open Folder” button, and navigate the explorer to the CSE 232 folder you created earlier. Near the top-left of the window, you should see an icon of files stacked onto one another. Open VSCode, and you should be presented with a welcome page. I recommend using an existing folder, or creating a new folder dedicated to CSE 232 content. Preparing VSCode for C++ĭownload and install the Stable version of Visual Studio Code here. You probably won’t use the clang or clang++ command again from this point onwards. To test that you have Clang installed, open Terminal and use the following command: You may already have this installed, if you had been working with terminal features before this class. The easiest way to get a C++ compiler is to use Apple’s provided Xcode tools, which comes packaged with a compiler called “Clang”. I recommend taking the time to update your system now if you are below version 10.13. You can check your MacOS version by clicking the Apple logo at the top-left, and selecting “About This Mac”. The following tutorial assumes you are running on MacOS version 10.13 (High Sierra) or later, but it’s possible that this tutorial may still work on older versions - we simply have no way of testing. You guys have everything we need packed into a single terminal command, provided by the Apple developers. Much of the Windows tutorial is spent just getting the Windows operating system setup with a “psuedo Linux environment”, called Windows Subsystem for Linux. Why do you guys have it so easy? Well, MacOS is based on the Unix OS family, and so you already have full access to Linux command-line tools - Windows users do not have this luxury. Congratulations on having a Mac! You guys most definitely have the easiest setup of the three (really, two) operating systems we provide tutorials for.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |