Objective Tcl API

From: Googie (googie_at_no.spam.org)
Date: 02/25/05


Date: Fri, 25 Feb 2005 23:25:14 +0100

Take a look at this short code:

int Func(clientData, interp, objc, objv)
    ClientData clientData;
    Tcl_Interp* interp;
    int objc;
    Tcl_Obj* const objv[];
{
    if (objc != 2)
    {
        Tcl_WrongNumArgs(interp, 1, NULL, "arg");
        return TCL_ERROR;
    }

    char* arg = Tcl_GetStringFromObj(objv[1], NULL);

    if (arg)
    {
        printf("1\n");
        printf("arg is: %s\n", arg);
    }
    else
    {
        printf("2\n");
    }

    // .........
}

I register this function (as extension) in Tcl interpreter and when I
call it, Tcl crashes, exactly after displaying:

1
arg is:

Why? What am I doing wrong? I have no problems with 'int argc, char*
argv[]' function arguments, but I want to switch to objective one.

-- 
Pozdrawiam (Greetings)!
Googie


Relevant Pages