[Israel.pm] pack & unpack and system architecture

Scott Weisman sweisman at pobox.com
Mon Sep 5 04:45:26 PDT 2011


You would have to provide more details, like the C compiler, flags, etc.

IIRC unless you specify otherwise, C aligns structure members on 4 or 8 byte
boundaries. You can force it to pack structs, which you want in your case.

On Sun, Sep 4, 2011 at 6:34 PM, Natty <aloha2004 at gmail.com> wrote:

> Hi,
>
> I've packed a C structure which looks similar to:
>
> struct  {
>   unsigned char _vMapping1[3]; //  on the system perl is running, it sums
> up to 3 bytes.
>   unsigned char _vMapping2[3];   // on the system perl is running, it sums
> up to 3 bytes.
>   short _uPnP;  //  on the system perl is running, it sums up to 2 bytes.
> }
>
> I think there are some fill bytes, which there shouldn't be I believe,
> since I am not getting what I'm expecting when using:
>
> my $bin = unpack('c[3]c[3]s',...);
>
> is there a module which will make my life easier to pack / unpack C
> structures / binary data?
>
> thanks,
>
>
>
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://mail.perl.org.il/mailman/listinfo/perl
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.perl.org.il/pipermail/perl/attachments/20110905/9c27960e/attachment.htm 


More information about the Perl mailing list