in reply to Win32::API::Struct and GetCursorInfo with PCURSORINFO
Win32::API::Struct->sizeof() seems not to compute correctly struct size when nesting them:
use strict; use warnings; use Win32::API; Win32::API::Struct->typedef('POINT', qw( LONG x; LONG y; )); my $Point = Win32::API::Struct->new('POINT'); print "sizeof('POINT') = " . $Point->sizeof() . "\n"; Win32::API::Struct->typedef('CURSORINFO', qw( DWORD cbSize; DWORD flags; HANDLE hCursor; POINT ptScreenPos; )); my $CursorInfo = Win32::API::Struct->new('CURSORINFO'); print "sizeof('CURSORINFO') = " . $CursorInfo->sizeof() . "\n"; Win32::API::Struct->typedef('MYSTRUCT', qw( DWORD cbSize; DWORD flags; HANDLE hCursor; )); my $Struct = Win32::API::Struct->new('MYSTRUCT'); print "sizeof('MYSTRUCT') = " . $Struct->sizeof() . "\n"; __DATA__ sizeof('POINT') = 8 sizeof('CURSORINFO') = 16 sizeof('MYSTRUCT') = 12
8 + 12 != 16
Update: investigating a bit more, the problem seems linked with structure member alignment computations used in sizeof method (and require more knowledge than I've available for now :-)).
Bug discovered in v0.40 of Win32::API::Struct and reported as bug#6757 "Win32::API::Struct->sizeof() seems not to compute correctly struct size when nesting them".
____
HTH, Dominique
My two favorites:
If the only tool you have is a hammer, you will see every problem as a nail. --Abraham Maslow
Bien faire, et le faire savoir...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Win32::API::Struct and GetCursorInfo with PCURSORINFO
by bulk88 (Priest) on Oct 19, 2012 at 08:51 UTC |