• 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: Where to include header files - relates to last question on variable scope
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Where to include header files - relates to last question on variable scope


  • Subject: Re: Where to include header files - relates to last question on variable scope
  • From: Chris Hanson <email@hidden>
  • Date: Sun, 31 Oct 2004 01:10:55 -0800

On Oct 31, 2004, at 12:43 AM, Ole Voss wrote:
Why do I have to include the header file of this singleton class in every
other class I use it in? Should the class not be available to the compiler
the moment it's included in the 'main.m'?

There is nothing special about a file named "main.m" in the compiler's eyes, so no, the class should not be available everywhere just because its header is included in a file named "main.m".

I'm missing something fundamental here - it's always like that :-)

Independent compilation. Essentially, the compiler is called once per implementation (.m, .c, .cpp, etc.) file and must be provided with a file that is both syntactically correct *and complete* in order to generate an object file. This is generally done by using the C preprocessor, via the #include or (in Objective-C) #import directive to bring in the text of another file.

Java is different, it actually has the compiler do all of the necessary package/class dependency tracking and examine other implementation and class and jar files, compiling additional implementation files into class files as necessary.

-- Chris

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
References: 
 >Where to include header files - relates to last question on variable scope (From: Ole Voss <email@hidden>)

  • Prev by Date: Singleton class -init being called twice?
  • Next by Date: Re: Singleton class -init being called twice?
  • Previous by thread: Where to include header files - relates to last question on variable scope
  • Next by thread: FW: Where to include header files - relates to last question on variable scope
  • Index(es):
    • Date
    • Thread