: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;

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;


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Luke J Crook wrote:

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…–
-==-
Jon Atkins
http://jonatkins.org/

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;


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Anthony
Conductor New York City Transit Subdivision B/Queens (EFVGR)

wow cool (:> ----- Original Message -----

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;


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Anthony
Conductor New York City Transit Subdivision B/Queens (EFVGR)


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

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.

Keith

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

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020722/4f8a5b29/attachment.pgp

First, thanks to all who answered my question.

I performed a sizeof() on the SDL_VideoInfo struct (excluding the
SDL_PixelFormat field), which returned 8 bytes total

typedef struct {
Uint32 hw_available :1;
Uint32 wm_available :1;
Uint32 UnusedBits1 :6;
// == 1 byte
Uint32 UnusedBits2 :1;
Uint32 blit_hw :1;
Uint32 blit_hw_CC :1;
Uint32 blit_hw_A :1;
Uint32 blit_sw :1;
Uint32 blit_sw_CC :1;
Uint32 blit_sw_A :1;
Uint32 blit_fill :1;
// == 1 byte
Uint32 UnusedBits3 :16;
// == 2 bytes
Uint32 video_mem;
// == 4 bytes
// SDL_PixelFormat *vfmt;
} SDL_VideoInfo;

-Luke> ----- Original Message -----

From: knghtbrd@bluecherry.net (Joseph Carter)
To:
Sent: Monday, July 22, 2002 3:32 PM
Subject: Re: [SDL] :1 ?

Yeah, do some math now… All those bits add up to … 32 bits.On Mon, Jul 22, 2002 at 04:03:46PM -0700, Luke J Crook wrote:

First, thanks to all who answered my question.

I performed a sizeof() on the SDL_VideoInfo struct (excluding the
SDL_PixelFormat field), which returned 8 bytes total

typedef struct {
Uint32 hw_available :1;
Uint32 wm_available :1;
Uint32 UnusedBits1 :6;
// == 1 byte
Uint32 UnusedBits2 :1;
Uint32 blit_hw :1;
Uint32 blit_hw_CC :1;
Uint32 blit_hw_A :1;
Uint32 blit_sw :1;
Uint32 blit_sw_CC :1;
Uint32 blit_sw_A :1;
Uint32 blit_fill :1;
// == 1 byte
Uint32 UnusedBits3 :16;
// == 2 bytes
Uint32 video_mem;
// == 4 bytes
// SDL_PixelFormat *vfmt;
} SDL_VideoInfo;


Joseph Carter Now I’ll take over the world

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.

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020722/1818e9b2/attachment.pgp