Here's a silly example of what I've been doing in unamanged c++:
struct birthday
{
unsigned int year : 13;
unsigned short month : 5;
unsigned short day : 6;
};
int main (void)
{
birthday bDay, bDay2;
bDay.year = 2012;
bDay.month = 12;
bDay.day = 12;
char* packetA[4];
int packetB;
memcpy(packetA, &bDay, sizeof(bDay));
memcpy(&packetB, &bDay, sizeof(bDay));
memcpy(&bDay2, packetA, sizeof(bDay2));
...
}
So far the only practical solution my google skills have found is to declare blocks of code 'unsafe' as necessarily to continue using memcpy. Does anyone know of a better way?
This post has been edited by Sublight: 13 December 2012 - 04:41 PM

New Topic/Question
Reply



MultiQuote



|