Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!brunix!rjd From: rjd@cs.brown.edu (Rob Demillo) Newsgroups: comp.sys.atari.st Subject: Help with bit field troubles in Laser C Message-ID: <34368@brunix.UUCP> Date: 29 Mar 90 04:33:30 GMT Sender: news@brunix.UUCP Reply-To: rjd@cs.brown.edu (Rob Demillo) Organization: Brown University Department of Computer Science Lines: 50 I have a bit (excuse the pun) of a problem I'd like some help with. I am bringing some C code that I wrote over from a UNIX system which is trying to do the following: set up bit fields within a 4 byte word. union that word to a 4 byte char string and a long. Essentially, the structure mappings look like: struct phred { unsigned long a:20; unsigned long b:11; unsigned long c:1; } ; union { struct phred ieee; char string[4]; float floater; } float_guy; This way, when I read a floating point number into float_guy.floater, I can get at the word in a variety of different chunks... Now, I've ported this code to a couple of machines, and it works fine, but, unfortunately...Laser C does not allow bit field assignments on anything other than unsigned ints, so it chokes on by unsigned long a:20, etc... ...looking at the K&R language description, it states as one of the caviats that bit fields should not cross int boundaries, and an int in Laser C is 2 bytes long. So, am I screwed, or can you folks suggest an alternative to what I want to do? (I *hope* so, otherwise I'm in for a *major* rewrite of my code, and what I'll be left with is an ST-specific peice of C code...I hate that. So, any suggestions? Thanks in advance..... -- Rob - Rob DeMillo | Internet: rjd@brown.cs.edu Brown University | Also Internet: demillo@juliet.ll.mit.edu Planetary Science Group | Reality: 401-273-0804 (home) "I say you *are* the Messiah, Lord! And I ought to know, I've followed a few!"