This is documentation for Mathematica 6, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
MathLink C Function


int MLGetFunction(MLINK link, const char **s, int *n)
gets a function with a symbol as a head from the MathLink connection specified by link, storing the name of the symbol in s and the number of arguments of the function in n.
  • MLGetFunction() allocates memory for the character string corresponding to the name of the head of the function. You must call MLReleaseSymbol() to disown this memory. If MLGetFunction() fails and the function's return value indicates an error, do not call MLReleaseSymbol() on the contents of s.
  • External programs should not modify the character string s.
  • MLGetFunction() returns 0 in the event of an error, and a nonzero value if the function succeeds.
  • Use MLError() to retrieve the error code if MLGetFunction() fails.
  • MLGetFunction() is declared in the MathLink header file mathlink.h.
#include "mathlink.h"

/* read a Mathematica function from a link */

void f(MLINK lp)
    const char *f;
    int n;

    if(! MLGetFunction(lp, &f, &n))
            /* unable to read the function from lp */

    /* ... */

    MLReleaseSymbol(lp, f);