Exercises, examples and other material relating to training module U117. This topic is presented on public courses Learning to program in Lua
, Lua Programming
|Articles and tips on this subject||updated|
|1844||Calling functions in C from your Lua script - a first HowTo|
This short article shows you how to call a function that's written in C from a program written in Lua, how to write the function that's called, and how to turn it into an appropriate library and load that library. It then goes on (as a second example) to show you how to pass variables from the Lua script ...
|1845||Passing a table from Lua into C|
In a previous article, I showed you a simple example of how you can call a function that's written in C from Lua, and a second example that extended that - passing simple parameters in to the C function, and returning results.
But it's often more complex that that - for example, you may with to pass ...
|2461||Luac - getting lua to start fast by precompiling|
Luac is Lua's Compiler ... using "luac" you can turn your Lua program into a binary (executable) file. Covered on Installing Lua on our Lua Programming and Learning to program in Lua courses.
usage: luac [options] [filenames].
Available options are:
- process stdin
-o name ...
Examples from our training material
|candy.c|| C code callable from Lua - Mk 3|
|fromlua.c|| C code callable from Lua - Mk 1|
|getos|| What is my host operating system (in Lua)|
|luapassing.c|| C code - callable from lua with parameters passed|
|passing.lua|| Lua code that calls a C function, passing params and returning value|
|top.lua|| Lua program that loads and runs C code|
|wrapper.lua|| Lua script to load and run C functions - Mk 3|
Some modules are available for download
as a sample of our material or under an Open Training Notes License
for free download from http://www.training-notes.co.uk
Topics covered in this module
Using Lua and C together.
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule
Well House Consultants specialise in training courses in
. We run
throughout the UK (and beyond for longer courses), and
at our training centre in Melksham, Wiltshire, England.
It's surprisingly cost effective to come on our public courses -
even if you live in a different
country or continent to us
We have a technical library of over 700 books on the subjects on which we teach.
These books are available for reference at our training centre. Also
available is the Opentalk
Forum for discussion of technical questions.