Hi,
I have some c code that I have put into my qt5 program but I get a lot of old-style-cast warnings which I would like to get rid of but don't quite know how to. I have tried reinterpret_cast but either I'm doing it incorrectly or it is not the right thing to do as it still results in the same error... 
Thanks in advance!
warning: use of old-style cast [-Wold-style-cast]
warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
warning: use of old-style cast [-Wold-style-cast]
warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
To copy to clipboard, switch view to plain text mode
Example code:
unsigned int j,k;
unsigned int* jj;
char* cptr;
char buff[50];
jj = (unsigned int*)&tmpY; //recast as int as expected in htonl
j = htonl(*jj); //convert to network format
cptr = (char*)&j; //recast as a char * so can use indexing
sprintf(buff,"Y=%7.2f ",tmpY);
tmp=buff;
s.append(buff);
for(i=0;i<YLen;i++)
{
msg[YIndex+i] = cptr[i];
}
unsigned int j,k;
unsigned int* jj;
char* cptr;
char buff[50];
jj = (unsigned int*)&tmpY; //recast as int as expected in htonl
j = htonl(*jj); //convert to network format
cptr = (char*)&j; //recast as a char * so can use indexing
sprintf(buff,"Y=%7.2f ",tmpY);
tmp=buff;
s.append(buff);
for(i=0;i<YLen;i++)
{
msg[YIndex+i] = cptr[i];
}
To copy to clipboard, switch view to plain text mode
Bookmarks