Second, it seems not that easy to make it parse time.h, you may have to add some include directories and define some macros, depending on the system, so it is not that portable. I stopped with this:$ perl -V:timeincl timeincl='/usr/include/x86_64-linux-gnu/sys/time.h /usr/include/time.h + ';
And it gave meuse 5.010; use strict; use warnings; use Convert::Binary::C; use Config; my $c = Convert::Binary::C->new; $c->Include( '/usr/include', '/usr/include/x86_64-linux-gnu/sys/', '/usr/include/x86_64-linux-gnu/' )->Define('__WORDSIZE=64'); $c->parse_file('/usr/include/x86_64-linux-gnu/sys/time.h'); my $timeval = $c->pack( 'struct timeval', { tv_sec => 1, tv_usec => 0 +} );
I probably would be able to make it work on my particular system, but not in general case. And it requires that includes were installed on a target system, which may not be the case.bits/wordsize.h, line 7: macro '__WORDSIZE' redefined unidentically included from /usr/include/x86_64-linux-gnu//sys/cdefs.h:378 included from /usr/include/features.h:357 included from /usr/include/x86_64-linux-gnu/sys/time.h:23 at pack_ +timeval2.pl line 10.
In reply to Re^2: Packing struct timeval
by zwon
in thread Packing struct timeval
by zwon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |