Re: Unable to Compile Simple Application (Errors)
Re: Unable to Compile Simple Application (Errors)
- Subject: Re: Unable to Compile Simple Application (Errors)
- From: Kyle Sluder <email@hidden>
- Date: Sun, 27 Sep 2009 21:13:10 -0700
There should be more than just that one line.
C requires that functions be declared before they are used; if they
are not, it assumes they take any number of parameters and return an
int. At the points at which you call colorName, the compiler hasn't
seen a declaration for colorName yet, but can infer that it is a
function from the way you're using it. So it assumes it's "int
colorName()" and continues on its merry way. Then when it sees your
definition of colorName later on, it complains because the definition
"NSString *colorName(ShapeColor)" does not match the assumed "int
colorName()".
You have two options:
1. Provide a prototype of colorName somewhere before it is used.
Typically this is done in a header (.h) file which is #imported by the
source (.m) file.
2. Move the definition of colorName before it is used.
I also suggest you consult your favorite C language book for more. I
have always been partial to K&R.
--Kyle Sluder
_______________________________________________
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