Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!rutgers!sunybcs!boulder!hao!oddjob!gargoyle!ihnp4!alberta!ers!teletron!andrew From: andrew@teletron.UUCP (Andrew Scott) Newsgroups: comp.lang.c Subject: structure enhancements Message-ID: <112@teletron.UUCP> Date: Wed, 14-Oct-87 18:28:31 EDT Article-I.D.: teletron.112 Posted: Wed Oct 14 18:28:31 1987 Date-Received: Fri, 16-Oct-87 07:13:42 EDT Organization: TeleTronic Communications Ltd., Edmonton, Alta. Lines: 48 Keywords: structure bitfield wish I'm not really up on what the ANSI C committee is doing, and these topics may have been discussed before (although I haven't seen them), but I'd like to toss out a few ideas on "things I'd like C to do" for discussion: 1. structure equality/inequality operators I'd like to see the == and != operators apply to structure variables. If structure assignments are allowed (as they are in many compilers), why not allow (in)equality operators also? 2. appropriate bitfield sizing It would be convenient if one could specify how much space a bitfield structure was stored in (instead of always defaulting to int). I'd like to be able to do things like this: struct message { struct { unsigned type : 2; unsigned ack : 3; unsigned seq : 3; } header; char text[253]; short crc; }; The intent is for the 'header' to be stored as an 8 bit quantity. Without this, I declare 'header' as a char and use masks to extract specific fields. Yuk. It's difficult to use bitfields structures to define "templates" for real world data formats as they now stand. 3. bitfield comparisons I guess this is related to point 1 above, but I'd like to be able to use bitfield structures in comparisons, such as if (ma.header == mb.header) .. I've used unions of ints and bitfield structures to get around this, but that's a fairly gross hack just to get around a syntactic restriction. I'd appreciate hearing what people have to say about these ideas. Are they stupid, strange, unimplementable or what? Andrew