Jump to content
  • Advertisement
Sign in to follow this  
iram

using pointer access

This topic is 4971 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

i have the following function in angelscript. cannot pass the address of an object over to the function, the compiler keep complaining about accessing error. how to do it correctly? void main() { Point3 p; p.x = 123; p.y = 456; p.z = 789; SC_Main_Point (&p); //cannot work!! } void SC_Main_Point (Point3 *po) { Console ("#####################"); ConsoleF (po->x); ConsoleF (po->y); ConsoleF (po->z); }

Share this post


Link to post
Share on other sites
Advertisement
Angelscript does not have that complete of pointer support. I'm fairly certain there is no address-of operator.

Share this post


Link to post
Share on other sites
AngelScript don't allow the manipulation of pointers, nor taking the address of variables, due to security reasons.

You can however pass parameters by reference, so doing the following would work:


void main()
{
Point3 p;

p.x = 123;
p.y = 456;
p.z = 789;

SC_Main_Point (p); // The point is passed by reference

}



void SC_Main_Point (Point3 &po)
{
Console ("#####################");
ConsoleF (po.x);
ConsoleF (po.y);
ConsoleF (po.z);
}

Share this post


Link to post
Share on other sites
that works gracefully!!

btw, how to compare whether a pointer is null in angelscript ?


i tried to no valid:

float *p;

if (p == NULL) //does not work
{

}

Share this post


Link to post
Share on other sites
NULL doesn't exist in AS 1.10.1, but you should be able to use 0.


if( p == 0 )
...


In AS 2.0.0 pointers don't exist as they do in C++, but there you have handles, which are basically smart pointers. With these you can compare with 'null' to verify if they are set or not.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!