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: Ole Voß <email@hidden>
- Date: Mon, 01 Nov 2004 09:07:33 +0100
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.
Surprise - that's what I'm doing!
And, among others, you are helping me - thank you for that.
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 would really like to learn this, but with all the information
available, all I need is a simple pointer in the right direction. Tell
me where I can find this 'all-encompassing how a C/Obj-C/XCode compiler
works' document and I'll read and understand 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.
But if I need the same class in my AppController (taking care of my menu
and stuff) and again in the PreferenceController (taking care of the
preference pane) - then I have to include the header file twice. I
thought that there would be a single file where I could include all
required header files so that I DONT have to do that.
'main.m' is obviously not the place to do that in, and so far nobody has
given me a hint (besides your mentioning the build-phase) - Should I
delve deeper into the build-phase or should I concern myself with the
nitty gritty of how a compiler works when all I want to know is where to
put global variables?
Regards,
Ole.
_______________________________________________
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