Artalus
Artalus

Reputation: 1162

Replace Visual Studio standard library

I am on Windows, and suppose I want to use different implementation of standard C++ library for my projects - say, libstdc++ or libc++.

  1. Is there a way to persuade my Visual Studio to use it instead of MSVC library, so I can still use #include <algorithm> and not #include <custom/algorithm>? I believe that I can achieve it by simply adding path to my headers into project, but I am looking for more "system-wise" way, so I wouldn't repeat it for every single project.
  2. Will it actually worth the hassle - specifically in terms of modern C++ features being available / standart-compliant?
  3. If so, what would be cons of such replacement, apart of possibility to use some features that are not present in other implementations?
  4. Particulary, answers to this question mention that there may be compatibility issues with other libs - does this apply only to Linux world, or will I have problems on Windows too?

Note: this is mostly a theoretical question - I'm fine with MSVC library, but I'd really like to know more about different stdlib implementations.

Upvotes: 3

Views: 2034

Answers (1)

Lightness Races in Orbit
Lightness Races in Orbit

Reputation: 385204

Theoretically it's not impossible to swap out stdlib implementations. With clang, you can choose between libc++ (clang's) and libstdc++ (GCC's).

However, in practice, stdlib implementations are often tied fairly fundamentally to the internals of the compiler they ship with, especially when it comes to newer-added C++ features, and this is not truer for many compilers than Visual Studio.

Could you make it work with a lot of hacking around? Maybe. Would it be worthwhile? I very much doubt it. Even if you succeeded, you will have sacrificed a reproducible build environment and will be relying on some deeply dark arts. Your project will not be reusable.

There is no indication in your question as you why you think you need to switch implementations, but it seems unlikely that any reason you could come up with would be worth the trouble.

Upvotes: 4

Related Questions