相关疑难解决方法(0)

什么是 ":-!!" 用C代码?

我在/usr/include/linux/kernel.h中碰到了这个奇怪的宏代码:

/* Force a compilation error if condition is true, but also produce a
   result (of value 0 and type size_t), so the expression can be used
   e.g. in a structure initializer (or where-ever else comma expressions
   aren't permitted). */
#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); }))
Run Code Online (Sandbox Code Playgroud)

怎么:-!!办?

c linux macros linux-kernel

1627
推荐指数
5
解决办法
18万
查看次数

C中的位域没有变量名

C中未命名的位域有什么用?

示例:

typedef struct fun {
unsigned int                 :8;
unsigned int foo1            :1;
unsigned int foo2            :1;
unsigned int foo3            :1;
unsigned int foo4            :1;
unsigned int foo5            :1;
}dig;
Run Code Online (Sandbox Code Playgroud)

有什么用途:

   unsigned int                 :8;
Run Code Online (Sandbox Code Playgroud)

c bit-fields

1
推荐指数
1
解决办法
1046
查看次数

标签 统计

c ×2

bit-fields ×1

linux ×1

linux-kernel ×1

macros ×1