Memory RAM address of a variable in Lua

2019-09-21 00:12发布

问题:

How to access in C++, the memory address of a variable declared in the language Lua???

in other words (example in written Lua):

X = 10

How to access the memory address of the variable X, which was declared on the Lua?

address = (&X) ?????????

Help me please!!

回答1:

You don't, you ask the Lua API for the value of the variable, or set it.

use :-

  • lua_getfield
  • lua_setfield

refer...

http://www.lua.org/manual/5.1/manual.html

for a description and examples.