Re: packing a C structure
- From: Ben Morrow <ben@xxxxxxxxxxxx>
- Date: Tue, 30 Oct 2007 07:12:44 +0000
Quoth bgeer <bgeer@xxxxxxxxxxxx>:
Check out "man perlfunc", then use "/" to search followed by " pack "
with the spaces & without the ".
Or use perldoc -f pack .
Note especially that if you want to put the resulting binary structure
on a network, that you should consider the difference between I (32
bit int) & N (unsigned long in network order).
On a 32-bit Intel, a long & int are the same size - I don't know why
there isn't a specific template character for "unsigned int in network
order".
n and N are 'unsigned 16-bit in network order' and 'unsigned 32-bit in
network order' respectively. Since they're meant for operations where
you are trying to be portable, a format for 'native int in network
order, whatever size it may be' is not likely to be useful. If you care,
$Config{intsize} will tell you the size of C's 'int' and $Config{ivsize}
will tell you the size of perl's integer variables (which will be
different if your perl was built to use 64 bits on a 32bit arch).
Ben
.
- References:
- packing a C structure
- From: haairam
- Re: packing a C structure
- From: jl_post@xxxxxxxxxxx
- Re: packing a C structure
- From: rams
- Re: packing a C structure
- From: bgeer
- packing a C structure
- Prev by Date: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.8 $)
- Next by Date: Re: Regex Help
- Previous by thread: Re: packing a C structure
- Next by thread: Re: packing a C structure
- Index(es):
Relevant Pages
|