Here is trivial example how to embedd Tcl into your C/C++ program.
Thre are implemented 2 custom commands available from TCL:
-
Command
::ex::uname_machinethat returns machine name from uname(2) system call. -
Command
::ex::uptime_secondsthat returns number of seconds from system start (uptime) from sysinfo(2) system call.
Pleae see also Embedding LUA into C/C++ program for comparison.
WARNING!
Valgrind report lot of leaks but ... the threaded version uses pool of per-thread allocated memory - so it is much harder to interpret results...
Tested OS: Debian9.9 (Stretch)/amd64
Install following required packages:
sudo apt-get install build-essential tcl tcl-dev tcl-doc libtcl8.6-dbg \
git valgrindOptional: Install Eclipse with CDT (C/C++ development support):
sudo apt-get install eclipse-cdtTODO: import to Eclipse
Just invoke:
makeTo run example just invoke:
make runFollowing examples are run:
puts "Hello, world on [::ex::uname_machine]!"
puts "System uptime is [::ex::uptime_seconds] seconds."should produce output like:
Hello, world on x86_64!
System uptime is 12678 seconds.
To run example with valgrind(1) memory leak detector use:
make valgrindNOTE: See notice at the beginning of this readme...
- official Tcl embedding docs:
- nice "Tcl crash course" from OpenOCD author: