[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
casting ints to pointers
From: |
Sebastian Reitenbach |
Subject: |
casting ints to pointers |
Date: |
Wed, 28 Mar 2012 10:23:48 +0200 |
Hi,
with Terminal, there we cast an int to a (void *) which gives no warning on
i386, but compiling this on amd64, you get the warning about casting an int to a
pointer of different size.
[[NSRunLoop currentRunLoop]
addEvent: (void *)master_fd
type: ET_WDESC
watcher: self
forMode: NSDefaultRunLoopMode];
The master_fd comes from a forkpty() its the file descriptor that gets created,
which is supposed to be an int.
To get rid of the warning, I thought I can first cast the int to a intptr_t
before its getting casted to the void *.
[[NSRunLoop currentRunLoop]
addEvent: (void *)(intptr_t)master_fd
type: ET_WDESC
watcher: self
forMode: NSDefaultRunLoopMode];
Then the warnings will be gone, and it all still seems to work. But I'm unsure
whether this generally a good or silly idea.
Sebastian
- casting ints to pointers,
Sebastian Reitenbach <=