|
| From: | Paolo Bonzini |
| Subject: | [Qemu-devel] Re: [PATCH 02/40] elf: Add notes implementation |
| Date: | Mon, 01 Nov 2010 22:28:36 +0100 |
| User-agent: | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100921 Fedora/3.1.4-1.fc13 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.4 |
On 11/01/2010 10:17 PM, Alexander Graf wrote:
Let's ask someone who definitely knows:).
LOL, hi Michael! :)
Michael, is code like
char *x = a, *y = b;
if (x < y) {
...
}
valid? Or do I first have to cast x and y to unsigned longs or uintptr_t?
It is, as long as x and y point into the same object (in your original code, data[0]...data[data_len] is the object). This instead
char *x = a;
long *y = b;
if (x < y)
{
}
should give a warning
g2.c:1: warning: comparison of distinct pointer types lacks a cast
but is also valid as long as x and y point into the same object. To
quiet the warning you should _not_ cast x to long* however (unless you
know it's properly aligned); casting y to char* instead is fine.
Paolo
| [Prev in Thread] | Current Thread | [Next in Thread] |