(I already submitted this to DevSupp, but why not share...)

In 4.0 DR2 header file Form.h, the internals of union FormObjectType should
NOT be protected by the ALLOW_ACCESS_TO_INTERNALS_OF_FORMS macro.  This
particular structure's internals should remain fully public.  Look closely:
it's just a union of pointers to other structures whose names are still
public.  Thus accessing the internal members of a FrmObjectType cannot
possibly cause harm or incompatibility.

Our code uses the FormObjectType union extensively, so it breaks badly with
4.0 DR2 because of this problem.  Our GetObjectPtr function uses it like
this:

    FormObjectType GetObjectPtr( FormType *pForm, UInt16 objectID )
    {
        FormObjectType obj;
        UInt16 i = FrmGetObjectIndex( pForm, objectID );
        obj.ptr = FrmGetObjectPtr( pForm, i );
        return obj;
    }

Note how it returns a FormObjectType union instead of the (void *) pointer
returned by FrmGetObjectPtr (though at the binary level they are the same
thing).  This lets our C++ code use clean union member access syntax instead
of ugly pointer casting:

    // note the ".control" union member access at the end:
    ControlType *pButton = GetObjectPtr( pForm, ButtonID ).control;

This code now fails to compile with 4.0 DR2.  But since this code merely
fetches a control pointer, there's no reason it shouldn't continue to work.

-slj-


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to