|
|
| There's more than one way to do things | |
| PerlMonks |
Re: A clean way to account for machine word sizes in XS code?by tonyc (Pilgrim) |
| on Aug 14, 2009 at 01:50 UTC ( #788483=note: print w/ replies, xml ) | Need Help?? |
|
For the typemap you need to add typemap entries that map your types to the same as the other int types, eg. in typemap:
ExtUtils::MakeMaker should pick up the type map automatically when you run Makefile.PL. As to whether those types are the correct types, one possibility is stdint.h, which requires a C99 compiler/libc, but in most cases, if the C compiler has 8 and 16 bit int types, char and short will be them. Unfortunately perl doesn't probe for stdint.h, so it's something you'd need to probe for yourself. For 32-bit, long might be 64-bit*, so in the absence of inttypes.h you could use limits.h:
* According to the standard, they could all be 128-bit, but most likely char is 8 bit if the compiler has an 8-bit type, and unless the compiler has stdint.h, short will be the 16 bit type if there is one.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||