After a few months of diving into JavaScript, I decided to jump into C++ to learn the fundamentals. However, I've been stuck for three days trying to get Visual Studio Code to compile a simple C++ program on my Mac. I've followed many tutorials, consulted ChatGPT, and installed various extensions, but every time I try to run a program, I find myself needing to paste new task or launch JSON files just to make it work.
Now I'm trying to use the `` library, but I can't even compile an empty `std::string name {};` declaration. I've been using Clang++ alongside a compile-and-run extension, but nothing seems to work. Is VS Code a poor choice for C++ development on Mac, or should I stick with easier, more flexible languages?
5 Answers
C++ can be really challenging, especially if you're getting started. Honestly, VS Code might not be the best fit for C++. If you're open to it, you could try switching to another compiled language like Java, which has a gentler learning curve and might be easier for you. If you do go this route, I'd recommend using an IDE like IntelliJ instead of VS Code, as it has a lot of built-in features that can simplify your workflow.
Have you tried running your compiler directly from the command line? This could help isolate whether the issue is with VS Code or your compiler setup. Save a simple C++ program, attempt to compile it using the command line, and see if you get any error messages that we can troubleshoot together. Here's a quick code snippet you could use to test:
```cpp
#include
#include
std::string name {};
int main() {
std::cout <> name;
std::cout << "Hello, " << name << 'n';
}
```
Honestly, I don't find VS Code great for C/C++ either. The setup can be quite a mess. If it's okay with you, I'd suggest giving CLion a try. It's designed for C++ development and could save you a lot of headaches!
You might just want to stick to the official VS Code documentation for C++ as your guide. They provide a good outline for setup and troubleshooting, which can be super helpful when you run into these issues.
This isn't really a problem with VS Code; it's mainly about getting your compiler working smoothly. I use LLVM and Clang without issues on Linux and Windows, and it should work on Mac too. Focus on making sure your compiler is set up correctly, and you can run your compile commands from VS Code once that's sorted out.

Thanks for the tip! I'm definitely considering Java after this experience—getting C++ running has been exhausting.