How to call a library function:
As Example the AddTail function of the Exec.library. first you need the parameter line and the offset of the function in the library both you can find in the includes of AROS for example: Includes/clib/exec_protos.h you will find this lines:
AROS_LP2(void, AddTail, AROS_LPA(struct List *, list, A0), AROS_LPA(struct Node *, node, A1), LIBBASETYPEPTR, SysBase, 41, Exec
This means its has 2 parameters (LP2),no return value (void) so its a procedure, the name is AddTail first parameter is a Pointer to a List (Pascal its a PList) with name list and so on. Most important the Library Base (SysBase = ExecBase) and Offset = 41. Now we bring all this together to a small function in pascal:
procedure AddTail(list: PList; Node: PNode); type TLocalCall = procedure(List: PList; Node: PNode; LibBase: Pointer); cdecl; var Call: TLocalCall; begin Call := TLocalCall(GetLibAdress(AOS_ExecBase, 41)); Call(List, Node, AOS_ExecBase); end;
Now this Library function can be used all over freepascal.
Take care with other libraries the Base must be open before using, ExecBase is an exception its always open to the program and accessible via AOS_ExecBase