Re: [fpc-pascal] struct definition in C

2014-03-24 Thread Michael Schnell
On 03/23/2014 08:12 PM, Luca Olivetti wrote: 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 AFAIK: mostly dependent on endianess of the arch. -Michael ___

Re: [fpc-pascal] struct definition in C

2014-03-24 Thread Michael Schnell
On 03/23/2014 08:44 PM, Jonas Maebe wrote: In part it's because no one has been able yet to come up with a natural way to specify them in Pascal. There was an interesting discussion on that in the mse forum (for the to-be-defined "mselang"). It might be worth looking there, as several viab

Re: [fpc-pascal] struct definition in C

2014-03-24 Thread Michael Schnell
On 03/23/2014 08:06 PM, Bernd Oppolzer wrote: I would like to add that bitfields in C are not at all portable; it is completely implementation dependant if they are allocated from right to left in the structure or the other way round etc.; I _found_ that in bitfield records, with high endian a

Re: [fpc-pascal] struct definition in C

2014-03-23 Thread Luca Olivetti
El 23/03/14 19:39, Darius Blaszyk ha escrit: > 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 spos

Re: [fpc-pascal] struct definition in C

2014-03-23 Thread Jonas Maebe
On 23/03/14 20:34, Darius Blaszyk wrote: Jonas Maebe schreef op 23 mrt '14: It's not an initialization, it's a struct with bitfields. FPC currently does not support C-compatible bitfield packing. To get a record with equal alignment and size you can declare it as "record data: cuint; end;", but

Re: [fpc-pascal] struct definition in C

2014-03-23 Thread Bernd Oppolzer
Am 23.03.2014 19:54, schrieb Jonas Maebe: On 23/03/14 19:39, Darius Blaszyk wrote: 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 initializatio

Re: [fpc-pascal] struct definition in C

2014-03-23 Thread Darius Blaszyk
Thanks Jonas! One more question. Why is it that there is no portable way to access the bitfields? Is that because of endian issues, or is there more to it? What about declaring the bitfields in a bitpacked record as "array of boolean"? Regards, Darius Jonas Maebe schreef op 23 mrt '14: > O

Re: [fpc-pascal] struct definition in C

2014-03-23 Thread Jonas Maebe
On 23/03/14 19:39, Darius Blaszyk wrote: 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

[fpc-pascal] struct definition in C

2014-03-23 Thread Darius Blaszyk
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? Kind reg