Skip to content

Latest commit

 

History

History
88 lines (56 loc) · 1.81 KB

README.md

File metadata and controls

88 lines (56 loc) · 1.81 KB

Embedding Tcl into C/C++ program

Here is trivial example how to embedd Tcl into your C/C++ program.

Thre are implemented 2 custom commands available from TCL:

  1. Command ::ex::uname_machine that returns machine name from uname(2) system call.

  2. Command ::ex::uptime_seconds that 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...

Setup

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 valgrind

Optional: Install Eclipse with CDT (C/C++ development support):

sudo apt-get install eclipse-cdt

TODO: import to Eclipse

Building example

Just invoke:

make

Running example

To run example just invoke:

make run

Following 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 valgrind

NOTE: See notice at the beginning of this readme...

Resources