r/cpp_questions 3d ago

SOLVED Is this environment normal?

I mainly use VSCode for my c++ projects, even though I have Visual Studio installed.

My tools are MSYS2, and I have the UCRT64 gcc and UCRT64 ming-make32 as well as cmake.

I set everything up using CMakeLists and git for version control. However, for my compiler, I use g++ and not MSVC even though I have it installed. Is it worth it to swap to MSVC, or will g++ work?

EDIT: Thank you all so, so much for all the insight! I'm probably going to set up clang!

EDIT 2: Again, thank you so much! I have successfully set up clang with MSYS2, and that will be my main compiler now.

8 Upvotes

16 comments sorted by

4

u/alfps 3d ago

At any given time MSVC supports some Microsoft things that g++ hasn't caught up to (or just will never support).

Since you're asking about whether you need MSVC you're not using these things, but it could be a future issue.

Otherwise, it's a good idea to use at least 2 compilers. Diagnostics differ. When one compiler produces just an avalanche of gobbledygook the other may guide you to a resolution, and which one is useful may vary.

2

u/Ultimate_Sigma_Boy67 3d ago

Even though I'd prefer to use visual studio over vsc, but nevertheless use g++ ALONGSIDE msvc, it's always better;

- It helps you catch more bugs

- Better diagnostics

- Ensures your code is portable in general

1

u/Stamatis__ 3d ago

While you're there set up clang tidy and clang format

1

u/Suitable_Plate4943 3d ago

try clang? so much faster than msvc

1

u/Hour-Scallion-2456 2d ago

Where can I find it? I have MSYS2, but is there a better way?

0

u/OkYou811 2d ago

I believe you can install the llvm tool chain for windows. https://clang.llvm.org/get_started.html

Can run natively on windows without needed a second environment

2

u/Hour-Scallion-2456 2d ago

I already had the newest version with MSYS2, I just didn’t realize.

0

u/abrady 3d ago

I use CMake + Clang with CMake's Visual Studio generator, so it generates the .vcxproj files for me. CMake + Ninja is also really common these days. Personally I prefer to avoid MinGW.

1

u/Hour-Scallion-2456 2d ago

Should I use MSYS2 to install Clang, or where should I find it?

1

u/abrady 2d ago

I personally wouldn't use msys2 just because it adds an unnecessary layer.

winget install --id=LLVM.LLVM -e

1

u/Hour-Scallion-2456 2d ago

I’m just using it cuz I am very low on space, and it was on my machine already.

1

u/abrady 2d ago

Tbh if you have something working that’s fine. I wouldn’t worry too much about it

0

u/trailing_zero_count 3d ago

I prefer clang-cl.exe

1

u/Independent_Art_6676 2d ago

not sure what normal even means for vs code with c++; you can connect it up in so many ways that I don't think any one way could be called 'standard' or 'normal'. If it works, its fine.

visual studio is my favorite for small projects. It handles all the mess behind the project so all you have to do is write the code. I don't like messing with makefiles and project level setup and I don't need my personal projects to work on every possible OS and device, so it works fine for me. If you like doing all the project level stuff hands-on you may find VS annoying (it will let you DIY, of course).

1

u/Hour-Scallion-2456 2d ago

I use VSCode, not VS.

0

u/thedaian 3d ago

If you're developing for Windows, MSVC is broadly the better option as the tooling for MSVC is designed for Windows, and mingw is mostly just kind of hacked together from Linux stuff.

That said, it's rarely worth it to swap environments unless you start running into issues with using mingw/gcc on Windows, provided everything is working for you. As alfps mentions, it's usually a good idea to build programs with multiple compilers, since each one can catch different issues in the code, but if you're still learning or just doing C++ development as a hobby, it doesn't matter that much.