Vin*_*982 6 c gcc literals variable-assignment bit-fields
在结构中读取pthread库,定义如下:
struct ptw32_thread_t_
{
....
int implicit:1;
......
};
Run Code Online (Sandbox Code Playgroud)
我知道它只占用1位然后如何给它赋值,因为激活溢出错误标志编译的每个值都会给出错误:
ptw32_thread_t *sp;
sp = (ptw32_thread_t *) calloc (1, sizeof(ptw32_thread_t));
sp->implicit = 1;
error: overflow in implicit constant conversion [-Werror=overflow]
Run Code Online (Sandbox Code Playgroud)
拥有1位是一个坏主意int
,因为它是一个有符号的类型.1
使用signed时,你不能代表使用1位,你只能代表0
和-1
,这有点奇怪.
解决方案就是成功unsigned int implicit : 1
.
归档时间: |
|
查看次数: |
398 次 |
最近记录: |