Sign in to follow this  

tolua allocated pointer problems

This topic is 4663 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Using lua 5.0.2 and tolua, i'm trying to access an allocated pointer (int *integers) in a global variable (mytest). I allocate the pointer in C, and try to access the values in my lua script: -- indices are 1-based for i=1,mytest.num_integers do printf( "integers: %d\n", mytest.integers[i] ); end However, I get an error: test.lua:17: attempt to index field '?' (a nil value) How can I get this to work? My class: class MYTEST { public: int num_integers; int *integers; }; extern MYTEST mytest; I allocate the global variable before calling my script, so I don't why it's telling me the pointer is nil: mytest.num_integers = 10; mytest.integers = new int[mytest.num_integers]; for(int i=0; i < mytest.num_integers; i++) { mytest.integers[i] = i; } [Edited by - raydog on March 10, 2005 10:22:03 PM]

Share this post


Link to post
Share on other sites

This topic is 4663 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this