Re: why is this result ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Jan 19, 2013 at 12:40 AM, horseriver <horserivers@xxxxxxxxx> wrote:
> On Sat, Jan 19, 2013 at 09:15:23AM +0100, Jędrzej Dudkiewicz wrote:
>> >> Because it's not possible to have an object with nonzero size.  The
>> >> address of every object must be unique, so they have to be separated by
>> >> one byte anyway.
>> >
>> >   thanks!
>> >   Here I do not define a object of type A ,just do sizeof operation to a A struct ,not a specified object.
>> >   So if I defined A a , does  sizeof(a) have the same mean with sizeof(A)  ?
>> >   what does the sizeof operator essentially?
>>
>> Yes, sizeof(a) and sizeof(A) are identical. I understand sizeof(expr)
>> as "tell me how many bytes I need to store result of expression expr"
> .
> When a is stored in one bytes, what is the mean or use of that byte data?

Apologies for sending this message only to you and not to gcc-help.

There is no use for this byte, it's only purpose is to avoid objects
of size 0, so you can say that it's wasted. But if you derive from
such class/struct, you get "empty-base-class-optimization", so no
space wasted here.
-- 
Jędrzej Dudkiewicz

I really hate this damn machine, I wish that they would sell it.
It never does just what I want, but only what I tell it.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux