MLUserData()

void * MLUserData(MLINK link, MLUserFunction *fp)
返回由 MLSetUserData() 安装的数据对象和函数指针.

更多信息更多信息

  • MLUserData()MathLink 的标头文件 mathlink.h 中被声明.

范例范例打开所有单元关闭所有单元

基本范例 (1)基本范例 (1)

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

typedef struct foo_ {
    int member;
} foo;


int main(int argc, char **argv)
{
    MLENV env;
    MLINK link;
    int error;
    foo *fobj;

    fobj = (foo *)malloc(sizeof(foo));
    if(fobj == (foo *)0)
        { /* unable to allocate memory for foo object */ }

    env = MLInitialize((char *)0);
    if(env == (MLENV)0)
        { /* unable to initialize MathLink environment */ }

    link = MLOpenArgcArgv(env, argc, argv, &error);
    if(link == (MLINK)0 || error != MLEOK)
        { /* unable to create link object */ }

    MLSetUserData(link, (void *)fobj, (MLUserFunction)0);

    /* ... */

    fobj = MLUserData(link, (MLUserFunction *)0);

    free(fobj);

    MLClose(link);
    MLDeinitialize(env);

    return 0;
}
New to Mathematica? Find your learning path »
Have a question? Ask support »