这是什么意思在C int类型的:16;? [英] what does this mean in c int a:16;?

查看:226
本文介绍了这是什么意思在C int类型的:16;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  

可能重复:结果
  什么是'无符号温度:3'的意思是


请,这是什么意思的符号


  

int类型的:16;


我发现它是code这样的,它不会编译。


  

结构名{
       int类型的:16; }



解决方案

这是一个位域

这特殊的位域没有多大意义,因为你只可以使用16位的类型,那你就浪费了一些空间作为位域填充到 INT

通常情况下,你使用它包含位大小的元素结构:

 结构{
    无符号nibble1:4;
    无符号nibble2:4;
}

Possible Duplicate:
What does 'unsigned temp:3' mean?

please what does this notation mean

int a:16;

I found it is code like this and it does compile.

struct name { int a:16; }

解决方案

This is a bitfield.

This particular bitfield doesn't make much sense as you just could use a 16-bit type and you're wasting some space as the bitfield is padded to the size of int.

Usually, you are using it for structures that contain elements of bit size:

struct {
    unsigned nibble1 : 4;
    unsigned nibble2 : 4;
}

这篇关于这是什么意思在C int类型的:16;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆