We can put our C/C++ routines into an interactive environment by co-compiling them along with Yazoo's source files. The process is shown below.
|First we need to adapt our function to communicate with Yazoo. A Yazoo function looks a lot like a stand-alone program in C, although the arguments are passed slightly differently (and the name can't be main()).|
|The second step is to introduce the function to Yazoo's userfn.c(pp) file: we write a pointer to the function and give it a name. Depending on how we do things, we may also have to include our source/header files somewhere and/or change the Makefile -- whatever will get it to compile.|
|Recompile Yazoo. Cross your fingers -- the author has this worked out on the machines that he uses, but every configuration seems to have a different personality so this may take some tweaking.|
|Optionally, we can wrap our function within a Yazoo class. This makes it much friendlier to work with from Yazoo's prompt. Additionally, Yazoo scripts automatically perform a number of services like typecasting that are tedious to check in C but dangerous to ignore.|
|Finally, we can run Yazoo and find our C/C++ function embedded in the language. The environment takes care of memory management. and makes it easy to load, save, print and change our variables. It is recommended to run Yazoo interactively -- i.e. without an argument -- because then all the functions from user.zoo will be pre-loaded.|
Last update: October 16, 2009