The Windows SDK contains a set of typedefs:
typedef long LONG; typedef struct tagPOINT { LONG x; LONG y; } POINT; typedef struct tagRECT { LONG left; LONG top; LONG right; LONG bottom; } RECT;
then there is a WinAPI function that expects a pointer to an array of POINT structures and the length of this array:
void ThatFunction( POINT* points, int numberOfElements );
and we have the following code:
RECT rect = ...//obtained from somewhere ThatFunction( reinterpret_cast<POINT*>( &rect ), 2 );
so RECT considered as an array of two POINT structures.
Is such a cast safe?
source share