NSApplicationMain const warning
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.