RE: [ILUG] gcc optimisation weirdness?

From: Paul Jakma (paul at domain clubi.ie)
Date: Wed 10 May 2000 - 23:04:38 IST


On Wed, 10 May 2000, Caolan McNamara wrote:

  These are not initializers, in this context : is to specify bitfields.

ah.. now that you say it, it sounds familiar. :)

i can't remember what i'm trying to think of.. some gcc extensions to
do with creating pre-initialised structs[1] (i think). used in linux
source in places... iirc. (but i'm probably utterly wrong).

  You can create a variable that refers to a unit whose size can be
  specified in bits. (and before people go mad using the damn things, the
  bitfields are collated together to form integral units (possible bytes,
  probably 32bit ints) and they are as slow as molasses)

why slow?

(eg if i had a lot of flags, and low-ranged integers, eg status
codes.. wouldn't i be much better off using bitfields to pack them
into a single 32 bit word? rather than having seperate variables,
where most of the space isn't used?)

what about 64bit machines? where you might waste even more space with
the standard variable sizes?
  
  i.e.
  int apple:4; creates a var apple which is 4bits long.
  You would not see :NULL in reality and god only knows what :0 would do

i was thinking of something else.
  
  C.

oh.. and apologies for the array mistake. for some reason i thought
arrays were declared with array[n], ie if i want the last element to
be array[9] i declare it as array[9].. doh... :)
  

-- 
Paul Jakma	paul at domain clubi.ie
PGP5 key: http://www.clubi.ie/jakma/publickey.txt
-------------------------------------------
Fortune:
In Corning, Iowa, it's a misdemeanor for a man to ask his wife to ride
in any motor vehicle.


This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:06:06 GMT