Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 May 2002 23:32:48 +0200
From:      Jens Schweikhardt <schweikh@schweikhardt.net>
To:        Marcel Moolenaar <marcel@xcllnt.net>
Cc:        Garrett Wollman <wollman@khavrinen.lcs.mit.edu>, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/sys/sys gpt.h
Message-ID:  <20020529233248.A24780@schweikhardt.net>
In-Reply-To: <20020529133846.E64995@kayak.xcllnt.net>; from marcel@xcllnt.net on Wed, May 29, 2002 at 01:38:46PM -0700
References:  <200205290258.g4T2wgF83137@freefall.freebsd.org> <9551.1022648961@critter.freebsd.dk> <20020529053653.GA306@dhcp01.pn.xcllnt.net> <20020529173621.B11817@chiark.greenend.org.uk> <20020529131927.C64995@kayak.xcllnt.net> <200205292027.g4TKRfnv031668@khavrinen.lcs.mit.edu> <20020529133846.E64995@kayak.xcllnt.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, May 29, 2002 at 01:38:46PM -0700, Marcel Moolenaar wrote:
# On Wed, May 29, 2002 at 04:27:41PM -0400, Garrett Wollman wrote:
# > <<On Wed, 29 May 2002 13:19:27 -0700, Marcel Moolenaar <marcel@xcllnt.net> said:
# > 
# > > 	what's the size of struct X { int64_t a; int32_t b; };
# > 
# > > There's no value in an answer that starts of with "It depends...".
# > > The size should always be 12 bytes, independent of any alignment
# > > requirements I may attach to it.
# > 
# > The C programming language does not work that way, and has never
# > worked that way.
# 
# I thought it was designed to be portable.

It is. The answer is sizeof (struct X). You are the one to make
nonportable assumptions by thinking there must be no padding.

# It looks to me that not
# being able to depend on such fundamental properties annihilate
# the goal of portability. Even a char does not have to be 8 bits
# anymore then...

Which makes C portable to systems where CHAR_BIT is 32, like many
of today's DSPs.

# I mean: sizeof(char x[20]) may then very well yield 21...

A portable C program wouldn't stop working if it was so.

# Ah, well... No point getting all "Don Quixote" about this...

Yes, there's a reason why C is the way it is :-)

Regards,

	Jens
-- 
Jens Schweikhardt http://www.schweikhardt.net/
SIGSIG -- signature too long (core dumped)

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020529233248.A24780>