2

how can I use c-struct in lua?

1
  • Please clarify. You need to pass a data scructure from C to Lua? Commented Aug 5, 2009 at 10:42

2 Answers 2

4

If you need to access fields in a C struct from Lua, set a userdata to the address of the C struct and set suitable metamethods to get and set fields.

Sign up to request clarification or add additional context in comments.

Comments

3

A terse question on a vast topic...
You can use, for example, the http://www.inf.puc-rio.br/~roberto/struct/ library, made by one of the Lua authors. There are alternatives, including writing your own C code to interface with Lua, access or build the structure, etc.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.