Thread overview | |||||
---|---|---|---|---|---|
|
March 19, 2003 Way to express bitfields? | ||||
---|---|---|---|---|
| ||||
In D, is there a way to express typedef struct { struct { union { unsigned long F1 : 25; unsigned long F2 : 7; }; unsigned long all; }; } Bitfields; and still have it fit in a single long? |
March 19, 2003 Re: Way to express bitfields? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steve Adams | Steve Adams wrote:
> In D, is there a way to express
>
> typedef struct {
> struct {
> union {
> unsigned long F1 : 25;
> unsigned long F2 : 7;
> };
> unsigned long all;
> };
> } Bitfields;
>
> and still have it fit in a single long?
No.
|
March 19, 2003 Re: Way to express bitfields? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steve Adams | On Wed, 19 Mar 2003 10:27:00 -0500, Steve Adams wrote:
> In D, is there a way to express
>
> typedef struct {
> struct {
> union {
> unsigned long F1 : 25;
> unsigned long F2 : 7;
> };
> unsigned long all;
> };
> } Bitfields;
>
> and still have it fit in a single long?
Is that written correctly? Why would you have a union of bitfields? The way it's currently written would take more than 4 bytes in C/C++ also.
Do you mean:
typedef struct
{
union
{
struct
{
unsigned long F1 : 25;
unsigned long F2 : 7;
};
unsigned long all;
};
} Bitfields;
? That only takes the space of one long.
--
// DDevil
|
Copyright © 1999-2021 by the D Language Foundation