• 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: Jiri Volejnik <email@hidden>
  • Date: Mon, 1 Nov 2004 12:31:27 +0100

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'?

Every source file is compiled separately in C, C++ and Objective-C. If there are some external declarations needed for the compilation, than you have to #include or #import the appropriate header file. If you need some declaration to be available in every source file of your project, then you also have to #include or #import the header file in every source file. That's simply the way it is.
If you really want some declarations to be available anywhere in your app without #importing it, you can declare it (or #import it) just once - in precompiled header. However, note that this is not the primary purpose of the precompiled header. Main purpose of the precompiled header is to speed up compilation. Only rarely changed declarations should therefore appear in the precompiled header. Every change in the precompiled header or in any header #imported by precompiled header will cause recompilation of all source files in your project.


Still, I think that you should not hang around a mailing list like cocoa-dev if you feel bothered by questions posed by people less-knowing than you. Afterall you might need help from me someday for something that does not seem 'basic' to you.

I'm surprised by this reaction. The guys were trying to help you, spending their time, although the question doesn't come under cocoa-dev. You could be RTFM'd instead.


-- Jirka

_______________________________________________
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


  • Follow-Ups:
    • Re: Where to include header files - relates to last question on variable scope
      • From: Ole Voß <email@hidden>
  • Prev by Date: Multiple Documents?! [newbie]
  • Next by Date: Re: Thread Cancelation
  • Previous by thread: Re: Multiple Documents?! [newbie]
  • Next by thread: Re: Where to include header files - relates to last question on variable scope
  • Index(es):
    • Date
    • Thread