El 23/03/14 19:39, Darius Blaszyk ha escrit:
Show quoted text 13 lines
Hi,
What would be the equivalent of the following struct definition in C?
typedef struct MyStruct
{
unsigned a :6;
unsigned b :15;
unsigned c:11;
}MyStruct;
I imagine this is some sort of struct initialization. Is thi spossible
in FPC as well, or what is the best alternative?
h2pas translates it to a record with associated setters/getters for each field.
You could also try with bitpacked records, i.e.
type MyStruct = bitpacked record
a:0..(1 shl 6)-1;
b:0..(1 shl 15)-1;
c:0..(1 shl 11)-1;
end;
but, as Jonas said, it't not guaranteed to work (in practice it works with win32/linux 32 and linux 64, though it could break with a different version of the compiler).
Bye
Luca