Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: another simple c question

Author: Daniel Clausen

Date: 03:25:59 07/21/04

Go up one level in this thread


On July 21, 2004 at 06:16:10, Daniel Shawul wrote:

>
>Isn't the size of a struct the sum of the sizes of its members.

Not necessarily. The compiler is free to add padding anywhere in the struct for
alignment reasons. That's also the reason why it's not safe to compare structs
with ==, since the padding bits are random. You have to write your own compare
function which basically compares field by field.

See also:
http://www.eskimo.com/~scs/C-faq/q2.13.html
http://www.eskimo.com/~scs/C-faq/q2.12.html
http://www.eskimo.com/~scs/C-faq/q2.8.html

Sargon



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.