Solved

What is the Compiler Doing?

Posted on 2000-02-25
2
194 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
Comment Utility
  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
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now