[fpc-pascal] How to create this "union" ?

Jeppe Græsdal Johansen jjohan07 at student.aau.dk
Mon Dec 26 19:51:50 CET 2011


Den 26-12-2011 19:49, Jonas Maebe skrev:
> On 26 Dec 2011, at 19:42, Jeppe Græsdal Johansen wrote:
>
>>>     union {
>>>         struct xt_entry_match **match;
>>>         struct xt_entry_target **target;
>>>     };
>>>     void *xt_entry;
>>>     void *udata;
>>> }
> ...
>>   case integer of
>>    0: (match: ^Pxt_entry_match; xt_entry, udata: pointer);
>>    1: (target: ^Pxt_entry_target);
>> end;
> While that does happen to work here, it's not a good way to translate such records because it's easy to make mistakes in case not all parts of the union are of the same size.
>
>
> Jonas_______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
True. I thought about it for some time, but realized that it is okay in 
this case because they are pointers. It's probably the same reason the 
comment is there in the C struct



More information about the fpc-pascal mailing list