[fpc-pascal]How to translate an Union from C to Pascal?
Jonas Maebe
jonas at zeus.rug.ac.be
Mon Oct 21 18:42:33 CEST 2002
On maandag, okt 21, 2002, at 17:37 Europe/Brussels, milimeter wrote:
> struct _GeditUndoAction
> {
> GeditUndoActionType action_type;
>
> union {
> GeditUndoInsertAction insert;
> GeditUndoDeleteAction delete;
> } action;
>
> gboolean mergeable;
>
> gint order_in_group;
> };
>
> I want to translate it to Pascal, but I don't know how to handle the
> union
> Action in it.
A union is the same as a variant record. Here's a possible translation:
type
TAction = record
case byte of
1: (insert: GeditUndoInsertAction);
2: (delete: GeditUndoDeleteAction);
end;
T_GeditUndoAction = record
action_type: GeditUndoActionType;
action: TAction;
mergeable: gboolean;
order_in_group: gint;
end;
Jonas
More information about the fpc-pascal
mailing list