Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!decvax!decwrl!turtleva!ken From: ken@turtleva.UUCP (Ken Turkowski) Newsgroups: net.lang.c Subject: Multiple character "character constants" Message-ID: <234@turtleva.UUCP> Date: Mon, 10-Oct-83 01:54:02 EDT Article-I.D.: turtleva.234 Posted: Mon Oct 10 01:54:02 1983 Date-Received: Thu, 6-Oct-83 20:16:41 EDT Lines: 41 I realize that I may be opening up a can of worms with this question, but I am trying to put together a package that will verify headers for files in a machine-independent way. Everyone knows that different machines have their own way of packing bytes into words and longwords. On the big-endian side are IBM and the 68000 with their (excuse me, K&R) struct long { char byte0, byte1, byte2, byte3; }; The little-endian VAX and the 16032 with struct long { char byte3, byte2, byte1, byte0; }; and the mongrel PDP-11 with struct long { char byte1, byte0, byte3, byte2; }; so that only the ordering of bytes in character arrays remains constant among different machines, not the ordering of bytes in shorts or longs. Machine independence therefore requires that programs treat the byte as the holiest quantum of information, and that all other data structures are derived from the ordering of bytes. Now, suppose that file headers are four bytes, and that it is desired to do a switch on this quantity. C does allow the use of multiple character "character constants", supposedly accommodating as many characters as can fit into an int. On a 32-bit machine, this means that 4 byte character constants can be constructed. For example, switch (headercode) { case 'eqn ': case 'nrff': case 'fort': case 'pasc': } Now, the question is this: how are the characters packed into the int? In the same way that strings would be packed into a 4-character array starting at the same address? This does seem most reasonable, although I can't seem to find anything definitive on the subject. Also, do all C compilers support the multiple character "character constants"? Ken Turkowski CADLINC, Palo Alto {decwrl,amd70}!turtlevax!ken