J
John May
I keep getting this warning in GCC with the code segment below.
file.c:256 "warning: dereferencing type-punned pointer will break
strict-aliasing rules"
/*****************************************/
char buffer[SIZE];
int length, type;
/* Code to fill buffer */
length = ntohs( *((unsigned short *)buffer) );
type = ntohs( *((unsigned short *)buffer + 1) );
/*****************************************/
I'm trying to take the first two bytes (in network byte order) off the
buffer and put them in the length, followed by the next two bytes into
the type. GCC complains about the length conversion, but not the type.
What does this warning mean, and should I bother with it?
I don't want to keep checking this forum, so answers by email required.
Quick responses appreciated.
John
file.c:256 "warning: dereferencing type-punned pointer will break
strict-aliasing rules"
/*****************************************/
char buffer[SIZE];
int length, type;
/* Code to fill buffer */
length = ntohs( *((unsigned short *)buffer) );
type = ntohs( *((unsigned short *)buffer + 1) );
/*****************************************/
I'm trying to take the first two bytes (in network byte order) off the
buffer and put them in the length, followed by the next two bytes into
the type. GCC complains about the length conversion, but not the type.
What does this warning mean, and should I bother with it?
I don't want to keep checking this forum, so answers by email required.
Quick responses appreciated.
John