#include question
From: Dan Moos (dan.moos_at_verizon.net)
Date: 02/29/04
- Next message: Leor Zolman: "Re: What is the difference in main"
- Previous message: Tom Del Rosso: "Re: Awainting Return Keypress"
- Next in thread: Jack Klein: "Re: #include question"
- Reply: Jack Klein: "Re: #include question"
- Reply: Leor Zolman: "Re: #include question"
- Reply: James Connell: "Re: #include question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 29 Feb 2004 19:26:59 GMT
hello group.
Okay, this is a very basic question.
Say I have a program who's source spans , oh say , 5 source files
(translation units as I found them called in Bjarne Stroustrup's book).
Lets say they all use some common header, say <vector>.
So they all #include <vector>
so if I understand it, the code in the header <vector> gets "inserted" into
5 different places in the toatal source code (all 5 translation units)
Is this what really happens, or does the linker somehow account for this and
only #include it once. I always thought that translation units were compiled
as seperate entities, and before linking, have no knowledge of each other,
and so I assume that, yes, they all get that code gets included. It just
seems uneccesary and inefficient to have multiple copies of the same code in
a project. I mean, in the end the linker makes it one big block of code
anyway.
I know about multiple inclusion guards, but doesn't that only protect
against multiple inclusion in the same translation unit? or are they
specifically for what I am asking about.
- Next message: Leor Zolman: "Re: What is the difference in main"
- Previous message: Tom Del Rosso: "Re: Awainting Return Keypress"
- Next in thread: Jack Klein: "Re: #include question"
- Reply: Jack Klein: "Re: #include question"
- Reply: Leor Zolman: "Re: #include question"
- Reply: James Connell: "Re: #include question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]