Oracle® Solaris Studio 12.4:C++ 用户指南

退出打印视图

更新时间: 2014 年 12 月
 
 

4.11.1 __has_attribute 函数式宏

预定义的函数式宏。

__has_attribute(attr)

计算结果为 1,如果 attr 是支持的属性。否则,计算结果为 0。用法示例:

#ifndef __has_attribute // if we don't have __has_attribute, ignore it
    #define __has_attribute(x) 0
#endif
#if __has_attribute(deprecated)
   #define DEPRECATED __attribute__((deprecated))
#else
   #define DEPRECATED // attribute "deprecated" not available
#endif
void DEPRECATED old_func(int); // use the attribute if available