Re: Help with linking and symbol resolution

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

 



On 2017-01-28 20:40 +0530, Lakshay Garg wrote:
> Yes, I get this warning too. But what I want to understand is why do
> we get the size of c as 8 when it should be 4 because the linker will
> find that there are multiple declarations of c and will keep the
> strong one which is the declaration with int.

It's wrong. The C Standard (ISO/IEC 9899:1999 6.5.3.4) said:

  The sizeof operator yields the size (in bytes) of its operand, which
  may be an expression or the parenthesized name of a type. The size
  is determined from the type of the operand.

Here the operand of sizeof is the expression c. Its type is double. So
the result is absolutely sizeof(double). Linkage is irrevalent.
-- 
Xi Ruoyao <ryxi@xxxxxxxxxxxxxxxxx>
School of Aerospace Science and Technology, Xidian University




[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