简体   繁体   中英

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.

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_ .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM