运营商规模的粒度 [英] granularity of size of operator

查看:85
本文介绍了运营商规模的粒度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

邮件

大家好..


是否可以找到结构大小到位大小..,其中

结构只包含一个元素,而且含有一个元素

说明符......例如......

struct x {

char a:4;

} y;


int main(){


printf(" struct的大小是%d \ n,sizoef(y)); //会给1

}


有没有什么方法可以让大小完全达到没有比特..所以对于

ex above .. size应该是4 ...,我可以通过

pragma禁用自动填充.. pragma的最小粒度仍然只有1个字节..

- 我认为编译器应该可以告诉这个东西..,这只是

问问编译器正确的事情..他是什么?

解决方案

chinuaécrit:


mail

hi all ..


是否有可能找到一个结构大小到位大小..,其中

结构只包含一个元素,而且含有位

说明符..例如..


struct x {

char a:4;

} y;


int main(){


printf(" struct of size is%d \ n",sizoef(y)); //会给1

}


有没有什么方法可以让大小完全达到没有比特..所以对于

ex above .. size应该是4 ...,我可以通过

pragma禁用自动填充.. pragma的最小粒度仍然只有1个字节..

- 我认为编译器应该能够告诉这个东西..,这只是问b / b
问问编译器正确的事情..他是



您使用的处理器可以寻址位?


我知道的大多数处理器中最小的可寻址单元

是1个字节。期间。


因为你不能少说话,所以没有任何意义可以获得尺寸

返回位尺寸。


"茅" < ch ********** @ gmail.comwrites:


是否可以找到最大比特大小的结构大小..,其中

结构只包含一个元素,而且含有一个元素

说明符......例如..


struct x {

char a:4;

} y;


int main(){


printf(struct的大小是%d \ n,sizoef(y)); //会给1

}


有没有什么方法可以让大小完全达到没有比特..所以对于

ex above .. size应该是4 ...,我可以通过

pragma禁用自动填充.. pragma的最小粒度仍然只有1个字节..

- 我认为编译器应该可以告诉这个东西..,它只是

问问编译器正确的事情..他是wh



任何对象的大小(除了位字段)总是一整个

字节数。


-

Keith Thompson(The_Other_Keith) ks***@mib.org < http://www.ghoti.net / ~kst>

圣地亚哥超级计算机中心< *< http://users.sdsc.edu/~kst>

我们必须做点什么。这是事情。因此,我们必须这样做。


jacob navia写道:


chinuaécrit:


mail

hi all ..


是否可以找到结构大小达到位大小..,其中

结构只包含一个元素,而且含有一个元素

说明符......例如..


struct x {

char a:4;

} y;


int main(){

printf(struct的大小是%d \ n,sizoef(y)); //会给1

}


有没有什么方法可以让大小完全达到没有比特..所以对于

ex above .. size应该是4 ...,我可以通过

pragma禁用自动填充.. pragma的最小粒度仍然只有1个字节..

- 我认为编译器应该可以告诉这个东西..,它只是

问问编译器正确的事情..他是wh



您使用的处理器可以寻址位?


我知道的大多数处理器中最小的可寻址单元

是1个字节。期。



Microchip PIC可以对地址进行寻址,大多数PIC C编译器都有
扩展来进行位寻址,但不是OP的方式写了它。

但是,没有CI知道可以实现malloc或sizeof位。


mail
hi all..

is it possible to find the size of a structure upto bit size.., where
the structure contains only one element and that too with bit
specifier..eg..

struct x {
char a : 4;
} y;

int main(){

printf("size of struct is %d\n",sizoef(y)); //will give 1
}

is there any way to get the size exactly upto no of bits.. so for the
ex above.. size should be 4..., i can disable ths automatic stuffing by
pragma.. still the smallest granularity for pragma is 1 byte only..
-- i think compiler should be able to tell this thing.., it is just
matter of asking the compiler right thing.. he wh

解决方案

chinu a écrit :

mail
hi all..

is it possible to find the size of a structure upto bit size.., where
the structure contains only one element and that too with bit
specifier..eg..

struct x {
char a : 4;
} y;

int main(){

printf("size of struct is %d\n",sizoef(y)); //will give 1
}

is there any way to get the size exactly upto no of bits.. so for the
ex above.. size should be 4..., i can disable ths automatic stuffing by
pragma.. still the smallest granularity for pragma is 1 byte only..
-- i think compiler should be able to tell this thing.., it is just
matter of asking the compiler right thing.. he wh

The processor you use can address bits?

The smallest addressable unit in most processors I know
is 1 byte. Period.

Since you can''t address less, there is no point in having sizeof
return bit sizes.


"chinu" <ch**********@gmail.comwrites:

is it possible to find the size of a structure upto bit size.., where
the structure contains only one element and that too with bit
specifier..eg..

struct x {
char a : 4;
} y;

int main(){

printf("size of struct is %d\n",sizoef(y)); //will give 1
}

is there any way to get the size exactly upto no of bits.. so for the
ex above.. size should be 4..., i can disable ths automatic stuffing by
pragma.. still the smallest granularity for pragma is 1 byte only..
-- i think compiler should be able to tell this thing.., it is just
matter of asking the compiler right thing.. he wh

The size of any object (other than a bit field) is always a whole
number of bytes.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.


jacob navia wrote:

chinu a écrit :

mail
hi all..

is it possible to find the size of a structure upto bit size.., where
the structure contains only one element and that too with bit
specifier..eg..

struct x {
char a : 4;
} y;

int main(){

printf("size of struct is %d\n",sizoef(y)); //will give 1
}

is there any way to get the size exactly upto no of bits.. so for the
ex above.. size should be 4..., i can disable ths automatic stuffing by
pragma.. still the smallest granularity for pragma is 1 byte only..
-- i think compiler should be able to tell this thing.., it is just
matter of asking the compiler right thing.. he wh


The processor you use can address bits?

The smallest addressable unit in most processors I know
is 1 byte. Period.

The Microchip PIC can address bits and most PIC C compilers have
extensions to do bit addressing though not the way the OP''s written it.
But yeah, no implementation of C I know can malloc or sizeof bits.


这篇关于运营商规模的粒度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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