Bits in C

shailu@research.trddc.ernet.in (Shailendra Abhyankar)
Wed, 2 Nov 1994 06:48:33 GMT

          From comp.compilers

Related articles
Bits in C shailu@research.trddc.ernet.in (1994-11-02)
| List of all articles for this month |
Newsgroups: comp.compilers
From: shailu@research.trddc.ernet.in (Shailendra Abhyankar)
Keywords: C, question, comment
Organization: Compilers Central
Date: Wed, 2 Nov 1994 06:48:33 GMT

Bits as data elements :
------------------------


I know that Bits are messy/non-portable etc, but nonetheless are
important to the programming community at large.


Languages like C, PL/I and Ada support bits, while others like PASCAL
do not.


I have the following question :


I have been wondering why C language only supports bits as members of
Structures. Initially I took this for granted, but after being deeply
involved with PL/I ( In particular a PL/I to C translator !! ), It
dawned upon me that bits as a stand-alone entity ( and not being members
of structures ) seems to provide a more natural way of thinking.


I know PL/I is messy ( I may be understating things ) as it deals with


- ALIGNED/UNALIGNED bit strings
- Bit Arrays
- Dynamic Bit strings
- Bit strings of length grater than the natural word size
- Bits as parameters
...




The one major difference between Bits and other data items is that bit
fields are not addressable.


But is it not possible that C allow independant Bit fields with restrictions
that the length of bit field not exceed the natural word size ?






Thanx
Shailendra Abhyankar


/-------------------------------------------------------------------------/


Shailendra Abhyankar e-mail shailu@trddc.ernet.in


Tata Consultancy Services Tel 91-212-622809
TRDDC, Pune -1
India
[I believe that the real problem is that there's no natural way to address
bit fields on most architectures, and since C allows you to turn anything
into a pointer to void, that'd either bulk up every single pointer or add
all sorts of horrible rules about what you were allowed to coerce bit pointers
into. -John]
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.