Path: utzoo!mnetor!uunet!husc6!bbn!bbn.com!rsalz From: rsalz@bbn.com (Rich Salz) Newsgroups: comp.lang.c Subject: Re: 'C' style etc... (really multi-char constants) Message-ID: <632@fig.bbn.com> Date: 15 Apr 88 15:20:53 GMT Organization: BBN Laboratories, Cambridge MA Lines: 20 >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@uunet.uu.net.