Subject: Re: Types sizes in C
To: Steven Grunza <steven_grunza@ieee.org>
From: Michael <macallan18@earthlink.net>
List: port-sparc64
Date: 04/08/2006 10:42:04
--Signature_Sat__8_Apr_2006_10_42_04_-0400_yC_V3q_4=i22c6VU
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

Hello,

> For code that must deal with hardware and thus is size specific, I
> tend to  include a function early in the program that checks the
> assumptions.
>=20
> #define         NUM_BYTES_IN_LONG               4
>=20
> if( sizeof(long) !=3D NUM_BYTES_IN_LONG )
> {
>     printf( "Dooh!  longs aren't 4 bytes long\n" );
>     exit( EXIT_FAILURE );
> }
>=20
> I tend to write programs to access the internals on PCI cards to do
> quick  diagnostics.  Having a simple sanity check helps keep the code=20
> portable.  Since it only runs once it's not a big performance issue.

Why waste code on such a test if you can use something size-safe in the
first place?

have fun
Michael

--Signature_Sat__8_Apr_2006_10_42_04_-0400_yC_V3q_4=i22c6VU
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (NetBSD)

iQEVAwUBRDfLv8pnzkX8Yg2nAQIGAAf9EyXBUH5/8DZBWEEAFMtRrerhB0ulGShH
oRcY7XTyl3H2imi7Ti3TpF6V55KjpiMPFDt5Oms8eHsppbidEyYmnnp6UJTXqScR
76CaNExP1qbooYX4dVERF989SkfsXIpG/M0NVh2p5xg6i1Dm3OlcnLlT46bhQLg2
ofSWidyyXbXoBfEj3KFJ/I2gX05zPnhc3n59icpfWB9a0AHUiMhiZstIZ9QiLKtC
pIu15x5k7UguHYd1jMIXJWz8yMzBbS0Qwk/BmkqeI91qcbGlqgO5JYVs6RKL+HYX
Hc5w2piELXLqTesV7YqnL1JXhOKTV5oqihLh3QDCSOe/1ERf1ZpYvw==
=K8h1
-----END PGP SIGNATURE-----

--Signature_Sat__8_Apr_2006_10_42_04_-0400_yC_V3q_4=i22c6VU--