Re: incompatible pointer type warnings
Re: incompatible pointer type warnings
- Subject: Re: incompatible pointer type warnings
- From: "Louis C. Sacha" <email@hidden>
- Date: Tue, 1 Jun 2004 18:36:56 -0700
Hello...
You are getting the warnings because the numberWithUnsignedLong:
class method is declared to return a pointer to a NSNumber, even
though the object created when you send the message to
NSDecimalNumber is actually a NSDecimalNumber.
NSDecimalNumber has it's own implementation of all the NSNumber
numberWith...: methods which create and return NSDecimalNumbers, so
there shouldn't be any reason why your code will break in the future.
You can fix the warnings by casting the returned pointers to
(NSDecimalNumber *)
microsecondsDN = (NSDecimalNumber *)[NSDecimalNumber
numberWithUnsignedLong:microsecondsSinceStartup.hi];
microsecondsDN = [microsecondsDN decimalNumberByAdding:
(NSDecimalNumber *)[NSDecimalNumber
numberWithUnsignedLong:microsecondsSinceStartup.lo]];
Hope that helps,
Louis
Though my application works, I am getting the following warnings, leading me
to fear future incompatibility:
MicrosecondsController.m:70: assignment from incompatible pointer type
MicrosecondsController.m:72: passing arg 1 of `decimalNumberByAdding:' from
incompatible pointer type
The relevant code:
...
microsecondsDN = [microsecondsDN decimalNumberByAdding:[NSDecimalNumber
numberWithUnsignedLong:(unsigned long)microsecondsSinceStartup.lo]];
...
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.