[fpc-pascal] Header translation, argument list, array of const?

Bernd prof7bit at gmail.com
Fri Jun 29 23:21:07 CEST 2012


Hello, I need to call the following function:


/**
 * Notifies Purple that a buddy's status has been activated.
 *
 * This is meant to be called from protocol plugins.
 *
 * @param account   The account the user is on.
 * @param name      The name of the buddy.
 * @param status_id The status ID.
 * @param ...       A NULL-terminated list of attribute IDs and values,
 *                  beginning with the value for @a attr_id.
 */
void purple_prpl_got_user_status(PurpleAccount *account, const char *name,
							   const char *status_id, ...) G_GNUC_NULL_TERMINATED;


I have translated it as follows:

procedure purple_prpl_got_user_status(account: PPurpleAccount;
  name_, status_id: PChar; par3: array of const); cdecl; external LIBPURPLE;

and I call it with [] as the last parameter because I never need it
anyways. This works in 50% of all cases, when it works it works
always, when I crashes (on x64 for example) then it crashes always.
When I slightly move around the function call, add some debug output
before and after the call so that the stack is layed out differently
(different garbage on the stack) then it will start working where it
previously crashed or crash where it previously worked.

How is this such a list of arguments actually implemented? is it on
the stack? What structure does it have? Can I somehow manually put
stuff onto the stack to make it think it is an empty list? maybe pass
another integer and pass 0 instead of this list?

Bernd



More information about the fpc-pascal mailing list