Re: Mysterious warning (comparison between pointer and integer)
Re: Mysterious warning (comparison between pointer and integer)
- Subject: Re: Mysterious warning (comparison between pointer and integer)
- From: Tommy Nordgren <email@hidden>
- Date: Wed, 11 Jul 2007 12:34:24 +0200
On 11 jul 2007, at 11.01, Stéphane Sudre wrote:
I have a warning in an Obj-C file that is quite mysterious to me:
warning: comparison between pointer and integer
Here is the source code:
// struct in6_addr address_;
- (NSString *) stringValue
{
char tBuffer[128];
if (IN6_IS_ADDR_LINKLOCAL(&address_) || IN6_IS_ADDR_MULTICAST
(&address_))
{
address_.__u6_addr.__u6_addr8[3]=0;
}
if (inet_ntop(AF_INET6,&address_,tBuffer,128)!=NULL) // *******
This is where the warning is reported.
{
return [NSString stringWithUTF8String:tBuffer];
}
return nil;
}
Yet according to the man page:
The function inet_ntop() converts an address *src from network format
(usually a struct in_addr or some other binary form, in network byte
order) to presentation format (suitable for external display
purposes).
The size argument specifies the size, in bytes, of the buffer
*dst. It
returns NULL
and headers:
const char *inet_ntop(int, const void *, char *, size_t);
the code looks correct.
I am probably missing something obvious or there's a bug in gcc.
NULL can expand to just a 0 or a (0) or a 0L or a (0L)
with some compiler settings. Replace NULL by the following to silence
the warning:
(char *) NULL
-------------------------------------
This sig is dedicated to the advancement of Nuclear Power
Tommy Nordgren
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden