Red Skotina
Red Skotina

Reputation: 90

Detect msvc standard library

How can I reliably detect msvc standard library via preprocessor?

Not msvc compiler with checking _MSC_VER but another compiler utilizing this library?

I'm looking for specific preprocessor macro like __MINGW32__ in mingw , __MINGW64_VERSION_MAJOR in mingw-w64

This just academic question.

Upvotes: 1

Views: 301

Answers (1)

Jonathan Mee
Jonathan Mee

Reputation: 38949

First off, don't compile the msvc libraries with another compiler, they depend upon msvc compiler behaviors and defines.

Secondly, there isn't anything in every msvc standard library header that you could use to test against. Even if there was it would be implementation defined and may also be defined by another standard library implementation.

That said #include <iostream> is about as close to universal as it gets. You could look through this file for a unique enough define that you could key off of. For example _IOSTREAM_.

Upvotes: 1

Related Questions