I'm trying to register this struct with AS:
struct Vector2d {
float x;
float y;
Vector2d();
Vector2d( const Vector2d& v );
Vector2d( float argX, float argY );
float length() const;
Vector2d normalize() const;
float distanceTo( const Vector2d& v ) const;
float dot( const Vector2d& v ) const;
};
And here is how I am trying to do the registration:
// Register our Vector
r = m_engine->RegisterObjectType("Vector2d", sizeof(Vector2d), asOBJ_VALUE | asOBJ_APP_CLASS | asOBJ_APP_CLASS_CONSTRUCTOR | asOBJ_APP_CLASS_DESTRUCTOR ); assert( r >= 0 );
r = m_engine->RegisterObjectBehaviour("Vector2d", asBEHAVE_CONSTRUCT, "void Vector2d()", asFUNCTION(DefaultCtor<Vector2d>), asCALL_CDECL_OBJLAST); assert( r >= 0 );
r = m_engine->RegisterObjectBehaviour("Vector2d", asBEHAVE_DESTRUCT, "void ~Vector2d()", asFUNCTION(DumbyFunc), asCALL_CDECL_OBJLAST); assert( r >= 0 );
r = m_engine->RegisterObjectProperty("Vector2d", "float x", offsetof(Vector2d,x)); assert( r >= 0 );
r = m_engine->RegisterObjectProperty("Vector2d", "float y", offsetof(Vector2d,y)); assert( r >= 0 );
r = m_engine->RegisterObjectMethod("Vector2d", "float length() const", asMETHOD(Vector2d, length), asCALL_THISCALL); assert( r >= 0 );
r = m_engine->RegisterObjectMethod("Vector2d", "Vector2d normalize() const", asMETHOD(Vector2d, normalize), asCALL_THISCALL); assert( r >= 0 );
r = m_engine->RegisterObjectMethod("Vector2d", "float distanceTo( const Vector2d@ v ) const", asMETHOD(Vector2d, distanceTo), asCALL_THISCALL); assert( r >= 0 );
r = m_engine->RegisterObjectMethod("Vector2d", "float dot( const Vector2d@ v ) const", asMETHOD(Vector2d, dot), asCALL_THISCALL); assert( r >= 0 );
But I get the following compiler warning:
Quote:
warning: invalid access to non-static data member 'Vector2d::x' of NULL object
warning: (perhaps the 'offsetof' macro was used incorrectly)
warning: invalid access to non-static data member 'Vector2d::y' of NULL object
warning: (perhaps the 'offsetof' macro was used incorrectly)
Any ideas why this might be?