Re: FW: Where to include header files - relates to last question on variable scope
Re: FW: Where to include header files - relates to last question on variable scope
- Subject: Re: FW: Where to include header files - relates to last question on variable scope
- From: Finlay Dobbie <email@hidden>
- Date: Sun, 31 Oct 2004 22:47:21 +0000
On Sun, 31 Oct 2004 23:10:27 +0100, Ole Voß <email@hidden> wrote:
>
You really shouldn't make it sound as if it was the most natural thing
>
in the world.
It really isn't that difficult.
>
Afterall, I don't include my '.m' files anywhere either
>
and they still get compiled - right?
I'm presuming you're using Xcode, in which case they were included in
your Target's Sources build phase.
>
So what's telling the compiler NOT to do it again? Is it the same
>
program that tells the compiler to forget that I already compiled that
>
class and forget that it exists unless I re-include it in the next
>
implementation that I need it in?
Each source file is a separate "compilation unit". Nothing's telling
the compiler to not do it again. It's just that each source file is
compiled in turn, including the headers it needs to do so, generating
an object file. At the end, all the individual object files are linked
together into a single binary. THis is all extremely basic stuff, I
think you need to go and learn it.
It doesn't "forget" anything. It's just that it is a different compilation unit.
>
Somehow this sounds awefully messy. Why would I want to tell the
>
compiler again and again and again that a certain class exists? Why
>
doesn't it just remember, that I have created this class and that I'd
>
like to use it - afterall if I didn't want to use it, why did I include
>
it in my project?
You don't have to tell the compiler again and again that a certain
class exists. You only have to include your headers once, when they're
needed. Think of each compilation unit as a separate discrete entity.
-- Finlay
_______________________________________________
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