On 21 Feb 2006, at 19:18, Derek Zhou wrote:

"Andrew Ruder" <[EMAIL PROTECTED]> writes:

2. make the ivar/setter generic somehow ... eg by using a void*
rather than an int.  Actually a windows handle is an unsigned long
thought I'm not sure it's guaranteed to stay that way ... using void*
in the generic part should be safe though.

The worst thing about the void * is that the number of warnings
generated on a amd64 machine is pretty staggering on NSStream.  I've
included a sample output below.  Can't this be done with typedef's?

- Andy
I don't have a 64bit machine so I cannot verify, but In
Foundation/NSRunloop.h there is:

- (void) addEvent: (void*)data
             type: (RunLoopEventType)type
          watcher: (id<RunLoopEvents>)watcher
          forMode: (NSString*)mode;

Where data is the file descriptor (int) in Unix. So how does that
work?

You call it as [loop addEvent (void*)(intptr_t)desc type: type watcher: watcher forMode: mode]

The double cast tells the compiler how to pass it and not to generate a warning.

The (intptr_t) tells it to extend an integer value to the size of a pointer. The (void*) tells it that it is OK to treat the value as an abstract pointer.

PS. I made sure the code in svn does not generate warnings.


_______________________________________________
Discuss-gnustep mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/discuss-gnustep

Reply via email to