Re: how to pack bitfields and make it cross container boundry

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Just a guess-- have you tried a char pack: 6 afterwards? It may be that,
given the luxury of using 16 bits anyway, the compiler decides to put b onto
a byte boundary, but if you use up all 16 bits, it will squeeze b closer to
a.

Worth a try I'd have thought.

S.

"Lokicer" <lokicer@xxxxxxx> wrote in message
news:OL2ZLAzTGHA.4080@xxxxxxxxxxxxxxxxxxxxxxx
hi,
i build a bitfield structure and pack it as following

#pragma pack(1)
typedef struct
{
char a:5;
char b:5;
} test_t;
#pragma pack()

i want b follows a closely and try it in vc++6, but there is 3 bits space
between a and b.

how to make bitfield corss byte boundry?

thanks in advance

Lokicer



.



Relevant Pages

  • Re: packing a C structure
    ... iam trying to pack a C structure to send via socket..i would like to ... char b; ... Sheesh, I sure hope Scott Nudds doesn't read this;-) It's "more" portable because you have removed alignment and endianness problems, there's still a portability issue in that the receiving machine might speak EBCDIC while the sending machine speaks ASCII. ...
    (comp.lang.perl.misc)
  • how to pack bitfields and make it cross container boundry
    ... i build a bitfield structure and pack it as following ... char a:5; ... #pragma pack() ...
    (microsoft.public.vc.language)
  • Re: packing a C structure
    ... char b; ... can u provide a guideline for the format in the Pack command that i ... memory, only how the language access it. ... vs little endian memory layout. ...
    (perl.beginners)
  • Re: packing a C structure
    ... char b; ... I have the impression that what you want is to pack values in Perl ... into a binary string of data that matches how a C program would do it. ... maximum of 15 characters), you probably want to replace "c16" in the ...
    (comp.lang.perl.misc)
  • Re: packing a C structure
    ... iam trying to pack a C structure to send via socket..i would like to ... char b; ... into a binary string of data that matches how a C program would do it. ... <YOUR PERL VARIABLES GO HERE>); ...
    (comp.lang.perl.misc)