Re: int problems on amd64
- From: "Liam R. E. Quin" <liam holoweb net>
- To: Fabio Rotondo <mlists rotondo it>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: int problems on amd64
- Date: Tue, 29 Mar 2005 16:12:11 -0500
On Tue, 2005-03-29 at 17:28 +0200, Fabio Rotondo wrote:
Roland Smith wrote:
[...] suppose you have to write a qsort callback:
void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const
void *, const void *));
suppose the "const void *" is actually an int value. By downcasting it
to int, gcc gives you a warning.
it'll be a pointer to an int, of course, not an int. But since an int
is smaller than a void *pointer, it'll work fine. The addresses might
sometimes overlap, but that's OK. That's why it's declared as a pointer
to an object of type "void".
The reason it's a warning and not an error to cast between pointer and
integer is that it's sometimes both necessary and correct. More often
you should cast between a pointer and a long, of course.
Liam
--
Liam Quin, W3C XML Activity Lead, http://www.w3.org/People/Quin
Pictures from old books: http://www.holoweb.net/~liam/pictures/oldbooks/
IRC (chat) programs: www.ircreviews.org/clients/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]