Re: C extension Clarification
From: David Gravereaux (davygrvy_at_pobox.com)
Date: 09/08/04
- Next message: Pat Thoyts: "Re: RPC in Tcl?"
- Previous message: Benjamin Riefenstahl: "Re: Tcl application deployment"
- In reply to: Noorul Ameen: "C extension Clarification"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 08 Sep 2004 11:56:59 -0700
noorul.ameen@gmail.com (Noorul Ameen) wrote:
>Dear Folks,
>
> I have a C code which is for some driver. I need to add it as tcl
>command. What needs to do. Is that we need to recompile the Tcl Source
>for it.
>
>Thanks in advance.
>
>
>Thanks & Regards,
>Noorul Ameen T
#include "tcl.h"
Tcl_ObjCmdProc MyCmd;
int
MyCmd (ClientData clientData, Tcl_Interp *interp, int objc,
struct Tcl_Obj * CONST objv[])
{
Tcl_SetObjResult(interp, Tcl_NewStringObj("hi there!", -1));
return TCL_OK;
}
#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLEXPORT
EXTERN int
Mycmd_Init (Tcl_Interp *interp)
{
#ifdef USE_TCL_STUBS
if (Tcl_InitStubs(interp, TCL_VERSION, 0) == 0L) {
return TCL_ERROR;
}
#endif
Tcl_CreateObjCommand(interp, "mycmd", MyCmd, 0L, 0L);
return TCL_OK;
}
compile it to a shared library with -DUSE_TCL_STUBS and linking to the
stubs library. name it mycmd.dll or mycmd.so or whatever your naming
format on your OS is.
-- David Gravereaux <davygrvy@pobox.com> [species: human; planet: earth,milkyway(western spiral arm),alpha sector]
- Next message: Pat Thoyts: "Re: RPC in Tcl?"
- Previous message: Benjamin Riefenstahl: "Re: Tcl application deployment"
- In reply to: Noorul Ameen: "C extension Clarification"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|