• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Mysterious warning (comparison between pointer and integer)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >Mysterious warning (comparison between pointer and integer) (From: Stéphane Sudre <email@hidden>)
 >Re: Mysterious warning (comparison between pointer and integer) (From: Alastair Houghton <email@hidden>)
 >Re: Mysterious warning (comparison between pointer and integer) (From: Stephane Sudre <email@hidden>)
 >Re: Mysterious warning (comparison between pointer and integer) (From: Alastair Houghton <email@hidden>)
 >Re: Mysterious warning (comparison between pointer and integer) (From: Tommy Nordgren <email@hidden>)

  • Prev by Date: Re: Mysterious warning (comparison between pointer and integer)
  • Next by Date: Re: HELP shortcut: Go to previous position
  • Previous by thread: Re: Mysterious warning (comparison between pointer and integer)
  • Next by thread: Re: Mysterious warning (comparison between pointer and integer)
  • Index(es):
    • Date
    • Thread