What breaks? (was Re: 64 bit longs?)
David Tanguay
datangua at watmath.waterloo.edu
Fri Jan 18 20:41:33 AEST 1991
In article <1991Jan18.044948.27943 at zoo.toronto.edu> henry at zoo.toronto.edu (Henry Spencer) writes:
>In article <14890 at smoke.brl.mil> gwyn at smoke.brl.mil (Doug Gwyn) writes:
>>There is no portable way to declare any integral type constrained to use
>>precisely 32 bits in its representation.
>
>There is no portable way to declare a type with *exactly* 32 bits, and
>a TCP/IP sequence number (for example) is exactly 32, no more.
How about: (Standard C only)
typedef struct { long it:32; } net32_t;
#define net32_t(var) var.it
and then all accesses to variables are wrapped in net32_t(var).
void
happy( void )
{
net32_t it;
...
net32_t(it) = 123456;
++net32_t(it);
net32_t(some_global) = net32_t(it) + 42;
...
}
I don't like sticking the 32 in the type name, since that may change,
so just consider the above as an illustration of a technique.
Ugly, I think, but it should accomplish what you want.
--
David Tanguay Software Development Group, University of Waterloo
More information about the Comp.lang.c
mailing list