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: Alastair Houghton <email@hidden>
- Date: Thu, 12 Jul 2007 11:56:29 +0100
On 12 Jul 2007, at 11:10, Tommy Nordgren wrote:
On 12 jul 2007, at 11.52, Alastair Houghton wrote:
On 12 Jul 2007, at 10:19, Stephane Sudre wrote:
I don't really understand why gcc does not just state that the
prototype is unknown.
Because that warning is not enabled by default using Xcode's
default project templates. I tend to enable more warnings in
projects I'm working on, just to avoid confusion like this; the
only downside is that some of the potentially useful warnings
trigger a lot for typical Objective-C code.
I've done some tests. Warnings about missing prototypes are simply
not shown, even if you enable all warnings in the target settings.
It appears necessary to compile files as Objective C++ instead of
as Objective C, to catch missing function prototypes.
No, it definitely works in Objective-C. Just to be certain, I just
tried to compile the following as a "Foundation Tool":
---- tstwarnings.m ----
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int ret;
ret = missing_fn(3);
[pool release];
return 0;
}
---- missing.c ---------
#include <stdio.h>
int missing_fn(int n)
{
printf ("Got %d", n);
return n + 1;
}
------------------------
and I got
tstwarnings.m:7: warning: implicit declaration of function
‘missing_fn’
Note that the warning you need is the one about implicit
declarations, not the one about missing prototypes (which only
triggers when you define a function that you haven't declared).
I don't think there's a checkbox for it in Xcode, so you either need
to set "Other Warning Flags" to include "-Wimplicit", or you can put
"-Wall" (or the Apple-specific "-Wmost") in there instead to turn on
lots of warnings all at once.
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
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