From: Michal Jaegermann <michal@ellpspace.math.ualberta.ca>
To: axp-list@redhat.com
Subject: Re: Whereis libm.a ?
Date: Mon, 9 Mar 1998 16:31:12 -0700 (MST) [thread overview]
Message-ID: <199803092331.QAA11122@ellpspace.math.ualberta.ca> (raw)
In-Reply-To: <Pine.GSO.3.96.980309154731.5369H-100000@yacht.ee.fit.edu> from "Christopher Curtis" at Mar 9, 98 03:52:59 pm
Christopher Curtis writes:
>
> Why does this program:
>
> #line 3823 "configure"
> #include "confdefs.h"
> #include <stdio.h>
> main()
> {
> FILE *f=fopen("conftestval", "w");
> if (!f) exit(1);
> fprintf(f, "%d\n", sizeof(char));
> exit(0);
> }
>
> tell me that the sizeof(char) is 0 ?
Because it is buggy.
C standard says that type returned by sizeof() operator is of an unsigned
integral type and is implementation defined ("integral type" does not
mean, of course, 'int'). But it also says that when sizeof is applied
to any object of structure, union or array then the result gives a total
number of bytes in such object, including any internal padding if present.
On 64-bit Alpha this requirement obviously makes a choice of 'unsigned
int' for a type of value of sizeof operator unfeasible.
On 32-bit machines sizeof(sizeof_t) happens to be the same as sizeof(int)
and the code above does accidentally what you expect. If you would use
-Wall to a compiler gcc would tell you loud and clear what it thinks
about this code.
Michal
prev parent reply other threads:[~1998-03-09 23:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-03-09 20:28 Whereis libm.a ? Christopher Curtis
1998-03-09 20:52 ` Christopher Curtis
1998-03-09 21:07 ` Christopher Curtis
1998-03-09 21:36 ` Richard Hadsell
1998-03-09 23:31 ` Michal Jaegermann [this message]
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox