Re: Passing argument with different width due to prototype: warning
Re: Passing argument with different width due to prototype: warning
- Subject: Re: Passing argument with different width due to prototype: warning
- From: Christopher Nebel <email@hidden>
- Date: Tue, 13 May 2008 18:41:20 -0700
On May 13, 2008, at 6:10 PM, R.L. Grigg wrote:
Im using Xcode 3.0 and building a Foundation Tool (debug, PPC). The
base SDK path is $(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk and Ive
included Foundation.framework in the project under "External
Frameworks and Libraries".
There is a line of my code that is giving me a warning I cant' douse:
#import <Foundation/Foundation.h>
. . .
NSSocketPort *socketPort=[[NSSocketPort alloc] initWithTCPPort:1234];
. . .
warning: passing argument 1 of 'initWithTCPPort:' with different
width due to prototype
I checked the NSPort header file for the NSSocketPort method
prototype, /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/
Foundation.framework/Versions/C/Headers/NSPort.h:
- (id)initWithTCPPort:(unsigned short)port;
What am I doing wrong?
Nothing, really, unless you count using -Wconversion in the first
place. -Wconversion isn't very useful these days -- it's mostly
intended for use when you're working with pre-ANSI C without function
prototypes. Quoting from gcc(1), -Wconversion warns "if a prototype
causes a type conversion that is different from what would happen to
the same argument in the absence of a prototype." Since unprototyped
integral arguments are passed as "int", a parameter that's explicitly
declared as any other integral type, such as "unsigned short", will
provoke this warning. Notice that it's how the *prototype* is
declared, not how you're calling the function, that causes the
warning, so there's nothing you can do to make it go away aside from
turning off -Wconversion.
--Chris Nebel
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden