Newsgroups: comp.lang.c Path: utzoo!utgpu!watserv1!watmath!datangua From: datangua@watmath.waterloo.edu (David Tanguay) Subject: Re: What breaks? (was Re: 64 bit longs?) Organization: University of Waterloo Date: Fri, 18 Jan 91 09:41:33 GMT Message-ID: <1991Jan18.094133.16879@watmath.waterloo.edu> References: <54379@eerie.acsu.Buffalo.EDU> <1991Jan15.053356.2631@zoo.toronto.edu> <1991Jan15.202123.14223@gjetor.geac.COM> <14890@smoke.brl.mil> <1991Jan18.044948.27943@zoo.toronto.edu> Lines: 32 In article <1991Jan18.044948.27943@zoo.toronto.edu> henry@zoo.toronto.edu (Henry Spencer) writes: >In article <14890@smoke.brl.mil> gwyn@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