How to include library feature macros like __cpp_lib_* if importing std only?

the library feature macros __cpp_lib_* are defined in header yvals_core.h (for visual C++) which is an implementation header and thus not meant to be included in cross platform libraries... So how can we obtain these macros in 3rd party library code that uses the standard library via

 
import std;


?



Last edited on
You do realize C++ code can still #include headers even with imports?
And you only need to include one header.

#include <version>

https://en.cppreference.com/w/cpp/header/version
Including <version> also defines all library feature-test macros.
Last edited on
Yes I know I can #include
Thanks!
Even though <version> was added to C++20 it isn't automatically added when using C++23's import std; or import std.compat; It has to be manually imported/#included to get access to the macros.

1
2
3
4
5
6
7
import std;
import <version>;

int main( )
{
   std::cout << __cpp_lib_any << '\n';
}


Compiles with nary a problem with VS 2022 as long as the C++ language standard is set to latest.
Topic archived. No new replies allowed.