• 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: Unable to Compile Simple Application (Errors)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Unable to Compile Simple Application (Errors) (From: Mick Walker <email@hidden>)

  • Prev by Date: Re: Unable to Compile Simple Application (Errors)
  • Next by Date: Re: NSBitmapImageRep caching behavior in Snow Leopard
  • Previous by thread: Re: Unable to Compile Simple Application (Errors)
  • Next by thread: Formatter and error windows (sheet AND modal)
  • Index(es):
    • Date
    • Thread