Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!lll-winken!uunet!mcvax!unido!tub!uwbln!ckl From: ckl@uwbln.UUCP (Christoph Kuenkel) Newsgroups: comp.lang.c Subject: bitfields considered harmful? Message-ID: <1473@uwbull.uwbln.UUCP> Date: 27 Apr 89 10:01:38 GMT Distribution: comp Organization: UniWare GmbH, Berlin Lines: 27 We have some software using C bitfields like in struct ... { unsigned active : 1, waiting : 1; ... }; During various ports of that to different SysV machines (should i have posted that to comp.unix.wizards?) we ran into problems because of compiler bugs. One time, assembler code was produced that tried to shift a word 0 bits to the right (68020), another time bitfields read nonzero all the time (iapx386), as in if (x.active) { /* always done */ } else { /* dead code */ } Now, are bitfields generally considered harmfull? Are there other good reasons to avoid them? what does ANSI C say about it? I like them cause they save space and are much more readable than oriing/anding with # defines and i dont have to bother with questions like how many flags fit into one int. thanx, christoph -- # include Christoph Kuenkel/UniWare GmbH Kantstr. 152, 1000 Berlin 12, West Germany ck@tub.BITNET ckl@uwbln {unido,tmpmbx,tub}!uwbln!ckl