Apologies is this is a general C question, but as I have only ever seen this
used before in SDL I thought I might ask it here. The SDL_VideoInfo struct
defines variables in the following way…
Uint32 hw_available :1; /* Flag: Can you create hardware surfaces? */
…Does the :1 mean that the hw_available variable is defined as a single
bit ?
-Luke
typedef struct {
Uint32 hw_available :1; /* Flag: Can you create hardware surfaces? /
Uint32 wm_available :1; / Flag: Can you talk to a window manager? */
…
} SDL_VideoInfo;
im not positive cause i too havent seen that before but i think thats a
default value for that member of the struct.> ----- Original Message -----
From: lcluke@wsbnet.com (Luke J Crook)
To:
Sent: Monday, July 22, 2002 1:02 PM
Subject: [SDL] :1 ?
Apologies is this is a general C question, but as I have only ever seen
this
used before in SDL I thought I might ask it here. The SDL_VideoInfo struct
defines variables in the following way…
Uint32 hw_available :1; /* Flag: Can you create hardware surfaces? */
…Does the :1 mean that the hw_available variable is defined as a single
bit ?
-Luke
typedef struct {
Uint32 hw_available :1; /* Flag: Can you create hardware surfaces? /
Uint32 wm_available :1; / Flag: Can you talk to a window manager? */
…
} SDL_VideoInfo;
Apologies is this is a general C question, but as I have only ever seen this
used before in SDL I thought I might ask it here. The SDL_VideoInfo struct
defines variables in the following way…
Uint32 hw_available :1; /* Flag: Can you create hardware surfaces? */
…Does the :1 mean that the hw_available variable is defined as a single
bit ?
It means that “hw_available” is a single bit in a 32 bit quantity, and the
hw_available/wm_available bits are part of the same UINT32.
Bitwise operators in C are ugly for a variety of reasons, but harmless in
this usage.
–>Neil-------------------------------------------------------------------------------
Neil Bradley What are burger lovers saying
Synthcom Systems, Inc. about the new BK Back Porch Griller?
ICQ #29402898 “It tastes like it came off the back porch.” - Me
Its a bit field, it means only one bit is allocated to that member
variable, as opposed to 32.
Atrix Wolfe wrote:> im not positive cause i too havent seen that before but i think thats a
default value for that member of the struct.
----- Original Message -----
From: “Luke J Crook”
To:
Sent: Monday, July 22, 2002 1:02 PM
Subject: [SDL] :1 ?
Apologies is this is a general C question, but as I have only ever seen
this
used before in SDL I thought I might ask it here. The SDL_VideoInfo struct
defines variables in the following way…
Uint32 hw_available :1; /* Flag: Can you create hardware surfaces? */
…Does the :1 mean that the hw_available variable is defined as a single
bit ?
-Luke
typedef struct {
Uint32 hw_available :1; /* Flag: Can you create hardware surfaces? /
Uint32 wm_available :1; / Flag: Can you talk to a window manager? */
…
} SDL_VideoInfo;
From: goumba_tony@yahoo.com (Anthony Thomasel)
To:
Sent: Monday, July 22, 2002 1:24 PM
Subject: Re: [SDL] :1 ?
Its a bit field, it means only one bit is allocated to that member
variable, as opposed to 32.
Atrix Wolfe wrote:
im not positive cause i too havent seen that before but i think thats a
default value for that member of the struct.
----- Original Message -----
From: “Luke J Crook”
To:
Sent: Monday, July 22, 2002 1:02 PM
Subject: [SDL] :1 ?
Apologies is this is a general C question, but as I have only ever seen
this
used before in SDL I thought I might ask it here. The SDL_VideoInfo
struct
defines variables in the following way…
Uint32 hw_available :1; /* Flag: Can you create hardware surfaces? */
…Does the :1 mean that the hw_available variable is defined as a
single
bit ?
-Luke
typedef struct {
Uint32 hw_available :1; /* Flag: Can you create hardware surfaces? /
Uint32 wm_available :1; / Flag: Can you talk to a window manager? */
…
} SDL_VideoInfo;
Uint32 hw_available :1; /* Flag: Can you create hardware surfaces? */
…Does the :1 mean that the hw_available variable is defined as a
single
bit ?
Yes, it’s a C bitfield. You can access individual bits if you need to, or
groups of bits (the number after the colon is the number of bits to use for
that variable).
They’re extremely rarely used, so it’s no surprise if you haven’t seen it
before.
It’s not as useful as you think. If you’ve only got one of them, it will
probably still allocate 32 bits. Likewise, if you have several with other
data elements in the struct between them, any that do not immediately
follow eachother can be expected to have their own ints.
Note further than 32 bit processors like to work with 32 bit numbers at a
time, so it wouldn’t make sense to use only 8 or 16 bits. I’m guessing at
32 because I’m assuming the gcc people realize this.
Even better, some compilers do not support (or simply ignore) bitfields.
Fun fun fun for the whole family!On Mon, Jul 22, 2002 at 01:25:37PM -0700, Atrix Wolfe wrote:
wow cool (:
–
Joseph Carter Sanity is counterproductive
abuse me. I’m so lame I sent a bug report to
debian-devel-changes
Every company complaining about Microsoft’s business practices is simply a
rose bush. They look lovely and smell nice. Once a lucky company dethrones
Microsoft they will shed their petals to expose the thorns underneath. A
thorn by any other name would hurt as much.