Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

What is the Compiler Doing?

Posted on 2000-02-25
2
199 Views
Last Modified: 2010-08-05
I am using VC++ 6.0.  What happens when a file such as #include<iostream> is inserted into several different files all within the same project?  Obviously, it is not necessary to include a file more than once but it seems to be done quite often.   Does this hinder the performance of the executable?  What exactly is happening?  Just wondering...
0
Comment
Question by:guile1
2 Comments
 
LVL 1

Accepted Solution

by:
Binder earned 100 total points
ID: 2559000
  No, it don´t hinder the performance of the executable, just
the performance of the compiler (a little bit). But there is a way
to minimize this effect. Looking at the start of iostream.h we found:

#ifndef _INC_IOSTREAM
#define _INC_IOSTREAM

....
#endif

   and of course several other lines of code. This means that
if the file wasn´t already included (if the symbol  _INC_IOSTREAM
wasn't defined yet) then the compiler includes it. If the symbol
was already defined, the compiler didn´t include it again.
0
 
LVL 22

Expert Comment

by:nietod
ID: 2559096
The use of #ifdef in that maner is very common.  It is necessary because C/C++ has rules against multiple definitions of the same "thing" in the same translation unit.  Without those #ifdef guards, the code would probably not compile.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question