Re: Phix: get_struct_size() returns eventually wrong size
- Posted by andreasWagner Sep 26, 2023
- 692 views
Thank you,
this works with 32bit, with 64bit i have to remove the #pragma pack(1) line to make it work.
My fault: I should have told you that it only failed with 32bit before and allready worked with 64bit.
Sorry
My first reaction: as I understand it there should be two bytes of padding after nCopies so that hInstance is aligned on a dword boundary.
Then I found this: https://www.vbforums.com/showthread.php?843083-RESOLVED-Len-LenB-PrintDlg-API-and-the-PrintDlg-structure
Guess I'll have to think about adding some kind of "align" flag to define_struct(), or maybe better if struct_str begins with "#pragma pack(1)"...
OK, I've pushed an updated cffi.e to the repository ( https://raw.githubusercontent.com/petelomax/Phix/master/builtins/cffi.e ) for you to test.
Should you prefer, the diff is here: https://github.com/petelomax/Phix/commit/04144e4fb7092c4321661a3a1d059a1c0cbcb39d
You'll have to insert #pragma pack(1) at the start of the definition of tPD (the blank lines should be optional):
constant tPD=""" #pragma pack(1) typedef struct tagPD { ... """