in reply to Win32::API::Struct problem

The reason is structure alignment (i.e. how the structure is stored in memory). I'd guess that it gets rounded up to the nearest DWORD boundary.

Running your snippet with $Win32::API::DEBUG=1 reveals some detail about what's going on:

use Win32::API; use Win32::API::Struct; $Win32::API::DEBUG = 1; Win32::API::Struct->typedef( test => qw(char i; long l;) ); my $b = Win32::API::Struct->new( 'test' ); print $b->sizeof;
Output:
(PM)Struct::recognize got 'i', 'char' -> 'c' (PM)Struct::recognize got 'l', 'long' -> 'l' (PM)Struct::new: got 'test' (PM)Struct::sizeof: sizeof with member(i) now = 1 (PM)Struct::sizeof: sizeof with member(l) now = 5 (PM)Struct::sizeof first=1 align=4 (PM)Struct::sizeof returning 8 8