gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: scan for int


From: Richard Frith-Macdonald
Subject: Re: scan for int
Date: Mon, 27 Jun 2005 10:17:19 +0100

On 2005-06-27 09:24:00 +0100 Riccardo <address@hidden> wrote:

Hello,

when using an NSScanner, I can scan for an int giving a variable or a nil pointer. The cocoa doc explicitly say I can do so in order to read a value and skip it. In gnustep it seems to work, but I get a compiler warning. Is this a gnustep problem? a gcc problem? "not a problem" :) I didn't check what OpenStep specs said bout this. It is not a serious problem but I just wated to know.

It's certainly not a gnustep problem ... it might be a compiler problem (I don't know what warning the compiler generated) ... but most likely it's a problem in your code and/or the Macos-X documentation.

The documentation *does* say you can pass a 'nil' ... but actually that's misleading, since 'nil' in Objective-C is a null object (ie it has type 'id'), but the method actually expects an argument whose type is pointer to integer.

Now, nil is actually a null pointer .... and a null pointer is what you must pass to scan the value without copying it, but the compiler may well be objecting about the type of the argument you are passing.

ie you should be doing

  [myScanner scanInt: (int*)0];

rather than

  [myScanner scanInt: nil];

to avoid any compiler warning.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]