• 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
NSApplicationMain const warning
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSApplicationMain const warning


  • Subject: NSApplicationMain const warning
  • From: René Puls <email@hidden>
  • Date: Wed, 5 May 2004 17:48:10 +0200

Hi,

I know this has come up before, but I want to ask a more general question for C geeks.

It is a known issue that the default Cocoa application project of Xcode has this main function:

int main(int argc, char *argv[])
{
return NSApplicationMain(argc, argv);
}

... which in turn generates a compiler warning "passing arg 2 of 'NSApplicationMain' from incompatible pointer type". This is due to the following declaration of NSApplicationMain in NSApplication.h:

APPKIT_EXTERN int NSApplicationMain(int argc, const char *argv[]);

So NSApplicationMain requires 'argv' to be an array of const char pointers. Why does it matter if I pass it a non-const array? It's not like I am forcing the function to modify the strings--if it wants to consider them constant, that is fine with me. Shouldn't the C compiler silently ignore this?

I could see the problem if it were the other way around, i.e. the function expecting non-const (writable) strings, but me passing constant (non-writable) ones. But why is there a problem in the opposite case, demonstrated above?

Kind regards,
Reni Puls
_______________________________________________
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.


  • Follow-Ups:
    • Re: NSApplicationMain const warning
      • From: Allan Odgaard <email@hidden>
    • Re: NSApplicationMain const warning
      • From: Nick Zitzmann <email@hidden>
    • Re: NSApplicationMain const warning
      • From: Ondra Cada <email@hidden>
  • Prev by Date: Re: Objective-C question
  • Next by Date: GLobal Variables and Object
  • Previous by thread: Re: Refreshing subviews
  • Next by thread: Re: NSApplicationMain const warning
  • Index(es):
    • Date
    • Thread