Is there a way for your program to determine this at compile time? Are there preprocessor macros you can use?
I know that g++ has this nice matrix of c++0x/c++11 feature support。其他流行的编译器是否存在?是否存在使用预处理器测试给定功能是否存在的标准方法(事实上的或其他方法)?
对此有一个问题,但是答案似乎并不完整:How to determine the version of the C++ standard used by the compiler?
我知道Boost.Config可以做到这一点,但是它是如何做到的呢?很高兴知道我是否出于某种原因不想使用Boost。
我将其作为副本关闭,因为有人编辑了answers in the original question使其更加完整。
最佳答案
查看__cplusplus
的值
http://predef.sf.net具有一些用于检测特定标准的值。
您链接到的问题上的Boost.Config recommendation也是很好的建议,并且提供了更细粒度的答案。我认为它基本上将feature matrix编码并定期更新它。
关于c++ - 您如何知道编译器支持哪个版本的ISO C++标准? ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7132540/