Subject: | packing a struct/member/field causes a bur error |
I'm using perl ver 5.6.1. I have a C struct with members with fields, i.e.,
"
use Convert::Binary::C;
#---------------------------------------------
# Create a new object and parse embedded code
#---------------------------------------------
my $c = Convert::Binary::C->new->parse( <<ENDC );
enum Month { JAN, FEB, MAR, APR, MAY, JUN,
JUL, AUG, SEP, OCT, NOV, DEC };
struct Date {
int year : 32;
enum Month month : 8;
int day : 32;
};
ENDC
#-----------------------------------------------
# Pack Perl data structure into a binary string
#-----------------------------------------------
my $date = { year => 2002, month => 'DEC', day => 24 };
my $packed = $c->pack( 'Date', $date );
"
The call to $c->pack causes a bus error. If I remove the " : " operators from the struct members, the call to pack works fine.
The above example is a simpilfied version of the actual C code that caused the problem. I hope this gives you enough info to reproduce the problem. Please let me know if I can help as I have been programming for over 25 years.
Regards,
Bill Waterman