• 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: Wed, 11 Jul 2007 11:42:46 +0100

On 11 Jul 2007, at 11:34, Tommy Nordgren wrote:

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

I don't believe that's the problem; zero is a special value (in terms of this warning anyway), which you can compare against *any* pointer.


i.e. if you do

  struct foo;

  int bar(void)
  {
    if ((char *)0x12345678 == 0)
      return 0;
    if ((struct foo *)0x12345678 != 0)
      return 0;
    if ((char *)0x12345678 == 1)
      return 0;
    if ((struct foo *)0x12345678 != 1)
      return 0;
    return 1;
  }

then you'll get

  tst.c: In function ‘bar’:
  tst.c:9: warning: comparison between pointer and integer
  tst.c:11: warning: comparison between pointer and integer

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
  • Follow-Ups:
    • Re: Mysterious warning (comparison between pointer and integer)
      • From: Tommy Nordgren <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: Tommy Nordgren <email@hidden>)

  • Prev by Date: Re: Mysterious warning (comparison between pointer and integer)
  • Next by Date: meta/command keybindings?
  • 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