Version 12 of What 'embedding' means

Updated 2011-03-22 11:54:51 by dkf

"BOOK Tricks of the Java Programming Gurus" has a chapter that illustrates the concept well.

RS: As a simple hint, you do embedding when your C code contains

#include <tcl.h>
...
  Tcl_Interp *interp = Tcl_CreateInterp(interp):
...

Then you can create new Tcl commands, link static variables from your C program to Tcl variables, but first of all have the power of Tcl at your fingertips ;-).


I thought there was at least one more call - to some sort of locating the encoding files, etc. function - required?

MJ - When embedding a complete Tcl install (e.g. with init.tcl) the following can be used to completely initialize the embedded Tcl interpreter (copied from TIP 66).

  Tcl_Interp * interp;

  /* Initialise the Tcl library thoroughly
  */
  Tcl_FindExecutable( argv[0] );

  /* Create the interp, evaluate "init.tcl" for the script
     level initialisation.
  */
  interp = Tcl_CreateInterp();

  if ( Tcl_Init( interp ) != TCL_OK ) {
     ... Report the error
  }