This feature is not supported on the Wolfram Cloud.

is a WSTP type that describes a function pointer to a function taking an WSLINK argument with a return type of void.


  • The function WSSetUserData() takes a WSUserFunction as its second argument. WSTP automatically calls the WSUserFunction at WSClose() time.
  • WSUserFunction is declared in the WSTP header file wstp.h.

ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

#include <stdlib.h>
#include "wstp.h"

typedef struct foo_
    int member1;
} foo;

/* destroy a foo object retrieved from a link */
void c(WSTPINK lp)
    foo *fobj;

    fobj = WSTPUserData(lp, (WSTPUserFunction *)0);
    if(fobj == (foo *)0) return;


/* allocate a foo object and store it in a link */

void f(WSLINK lp)
    foo *fobj;

    fobj = (foo *)malloc(sizeof(foo));
    if(fobj == (foo *)0)
        { /* error allocating space for foo object */ }

    WSSetUserData(lp, (void *)fobj, c);
Translate this page: