I have the following C structs:
typedef struct
{
char *a;
void *b;
} entry;
typedef struct
{
int size;
entry *entries;
} table;
So when i say
it will directly point to the entry, with the two pointers (
*a and
*b). However, when i try to convert this to Pascal:
table_entry = record
a: AnsiString;
b: Pointer;
end;
atable_entry = array of table_entry;
patable_entry = ^atable_entry;
table = record
size: integer;
entries: patable_entry;
end;
ptable = ^table;
and i try to pass a list from a Pascal executable to a C library, then it does not work, because
will not point to the item with the two pointers directly, but to a pointer to the item. So, this list in C
table_entry t_table_entries[] =
{
{"a", (void *)&a},
{"b", (void *)&b},
{"c", (void *)&c},
{"d", (void *)&d},
};
table t_table =
{
sizeof(t_table_entries) / sizeof(table_entry),
&t_table_entries[0],
};
can be passed to the C library, but this very same list in Pascal
t_table_entries: atable_entry =
(
(symbol: 'a'; funcptr: @a),
(symbol: 'b'; funcptr: @b),
(symbol: 'c'; funcptr: @c),
(symbol: 'd'; funcptr: @d),
);
t_table: table =
(
size: 4;
entries: @t_table_entries;
);
cannot. What i am doing wrong? Is it possible to store an
array of Record the same way as it is stored in C; the array directly containing the records and not pointers to each one? (I am aware that i could allocate memory directly for it and copy the items into it, but what i need is the identical initialization of the list from
const or
var.)