'C' style etc... (really multi-char constants)
Rich Salz
rsalz at bbn.com
Sat Apr 16 01:20:53 AEST 1988
>I never tried case 'ABCD' on a pdp-11, but I found case 'AB' quite
>useful.
The following is only slightly longer and completely portable:
case ('A' << 8) | 'B' :
if you know how big |int| and |long| are on the target machine, then
you can extend this as necessary. I've used the following macro
for code that's had to run on the Vax and Pyramid with shared semi-binary
data files.
#define PAIR(a,b) (((a) << 8) | (b))
switch (c = getword(infile)) {
case PAIR('H', 'L'):
...
case PAIR('H', 'I'):
...
}
--
Please send comp.sources.unix-related mail to rsalz at uunet.uu.net.
More information about the Comp.lang.c
mailing list