c - GCC 按位属性

标签 c gcc attributes

GCC 的 __attribute__(bitwise) 是什么意思? GCC-4.6 的信息页中未提及该属性。我在项目 Open-ISCSI 的源文件 open-iscsi-2.0.871/include/iscsi_proto.h 中偶然发现了它,它被用作

...
/*
 * If running svn modules we may need to define these.
 * This should not go upstream since this is already properly defined there
 */
#ifdef __CHECKER__
#define __bitwise__ __attribute__((bitwise))
#else
#define __bitwise__
#endif
#ifdef __CHECK_ENDIAN__
#define __bitwise __bitwise__
#else
#define __bitwise
#endif

/*! initiator tags; opaque for target */
typedef uint32_t __bitwise__ itt_t;
/*! below makes sense only for initiator that created this tag */
#define build_itt(itt, age) ((__force itt_t)\
    ((itt) | ((age) << ISCSI_AGE_SHIFT)))
#define get_itt(itt) ((__force uint32_t)(itt_t)(itt) & ISCSI_ITT_MASK)
#define RESERVED_ITT ((__force itt_t)0xffffffff)
...

我怀疑涉及字节顺序,但我无法理解上面给出的片段。

最佳答案

这显然不是 GCC 使用的,而是 Sparse 使用的,Linux 内核使用的 C 语义解析器。它记录在 Documentation/dev-tools/sparse.txt 中.

关于c - GCC 按位属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7931063/

相关文章:

Android C Select() 性能

c - 读取c中制表符分隔的文件

c++ - 在每个平台上包含来自同一文件的 header

c# - 通用类型属性的任何替代解决方案?

c - 使用 Tcl C API 的 Lib 崩溃,可能是由于错误的 refCount 使用

c++ - 在 C 中是否有一组标准的库用于动态字符串、列表和字典?

gcc - 不执行共享库构造函数

linux - 从 gcc 中删除 libgcc_s 依赖项

Python 双下划线修改

java - JSP EL 和范围属性混淆