NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Using C types in Perl (Score:1)
Thanks to jplindstrom for pointing me at Win32::API which already handles structs; I think I can modify that code to work on other platforms. What's a little sizeof between friends?
What I don't like about the way Win32::API handles structs is that it forces you to write the spec for each struct manually.
You probably also want to have a look at Convert::Binary::C [cpan.org], which allows for directly parsing C header files and using that information to pack/unpack binary data. It comes with a fully integrated C preprocessor, isn't limited to structs (handles unions, arrays, typedefs as well, and all of them recursively), and is highly configurable. It also has methods like sizeof or offsetof, and over 100k of POD. (end of ad... ;-)
I had something similar to P5NCI on my mind, probably based on libffi, and I think it's definitely useful. Nice work!
Reply to This