Created
September 30, 2021 10:29
-
-
Save sebres/f96e77aa1f73bbf988f4af247b86ed11 to your computer and use it in GitHub Desktop.
embedeval.c -- example of tcl-code embedding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* embedeval.c -- example of tcl-code embedding | |
* | |
* Compile: | |
* mingw: gcc -O2 -DUSE_TCL_STUBS=1 -I$tcl/win -I$tcl/generic embedeval.c -shared -o embedeval.dll libtclstub86.a | |
* *nix: gcc -O2 -DUSE_TCL_STUBS=1 -I$tcl/unix -I$tcl/generic embedeval.c -shared -o embedeval.so libtclstub86.a | |
* | |
* Usage: | |
* $ tclsh86 | |
* % load embedeval | |
*/ | |
#include "tcl.h" | |
/* ------------------------------------------------------------- */ | |
const char * tclCode = | |
"puts {this is embedded code};\n" | |
"puts \"2 + 2 equals [expr {2 + 2}]\";"; | |
int Embedeval_Init(Tcl_Interp *interp) { | |
if (!Tcl_InitStubs(interp, "8.5", 0)) { | |
return TCL_ERROR; | |
} | |
return Tcl_Eval(interp, tclCode); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment