473,396 Members | 1,765 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Stop recompiling if unchanged header codes?

"Load" and "Load2" are bound to "Include" while "Main" accesses variable
from "Include". I can only modify one source code before C++ compiler can
be able to compile one source code at this time so it does not need to
recompile all unmodified source codes. If I add or modify one header code,
it causes C++ Compiler to recompile all unmodified source codes. Why do it
do this?
How can I tell C++ Compiler's option to stop deleting all *.obj before
recompiling? All *.obj should remain unmodified while only one header code
can be compiled to create one object before one object can be linked to all
unmodified objects.
Please look at my code below for an example. Please let me know if
there is a way.

Bryan Parkoff

// Include.h
#if !defined(INCLUDE_H)
#define INCLUDE_H

extern int Total;
extern int Number;
extern int Number2;

void Run(void);

#endif // !defined(INCLUDE_H)

// Include.cpp
#include "Include.h"
#include "Load.h"
#include "Load2.h"

int Total = 10;
int Number = 12345;
int Number2 = 67890;

void Run(void)
{
Num();
Num2();
}

// Load.h
#if !defined(LOAD_H)
#define LOAD_H

void Num(void);

#endif // !defined(LOAD_H)

// Load.cpp
#include "Load.h"
#include "Include.h"

void Num(void)
{
Number *= Total;
}

// Load2.h
#if !defined(LOAD2_H)
#define LOAD2_H

void Num2(void);

#endif // !defined(LOAD2_H)

// Load2.cpp
#include "Load2.h"
#include "Include.h"

void Num2(void)
{
Number2 *= Total;
}

// Main.cpp
#include <stdio.h>
#include "Include.h"

int main(void)
{
printf("Hello...%d %d\n", Number, Number2);
Run();
printf("Hello...%d %d\n", Number, Number2);
return 0;
}

Jul 23 '05 #1
1 1264
Bryan Parkoff schrieb:
"Load" and "Load2" are bound to "Include" while "Main" accesses variable
from "Include". I can only modify one source code before C++ compiler can
be able to compile one source code at this time so it does not need to
recompile all unmodified source codes. If I add or modify one header code,
it causes C++ Compiler to recompile all unmodified source codes. Why do it
do this? If you modify Include.h both Include.cpp and Main.cpp need to be
recompiled. If you modify Load.h or Load2.h it should only recompile
Include.cpp
How can I tell C++ Compiler's option to stop deleting all *.obj before
recompiling? All *.obj should remain unmodified while only one header code
can be compiled to create one object before one object can be linked to all
unmodified objects.

Sorry, I don't really understand that sentence...headers are not
compiled, a translation unit is compiled. A translation unit consists
of a source (e.g. .cpp) file and everything directly or indirectly
#included by that source file.
If your IDE or "make" program invokes the compiler to recompile all
source files instead of only the ones that #include a changed header, it
does a poor job at determining dependencies. Either way, this is
specific to your IDE or "make" and as such not topical here - it's not a
C++ language issue. You will likely find a solution in a newsgroup
dedicated to your toolchain.

Cheers,
Malte
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ryan Liu | last post by:
All, Now I have meet a strange problems. When all the files have been compiled and when linking, make always recompiles some files. I don't know why. Would you mind giving some suggestion? The...
1
by: David Horowitz | last post by:
Hi folks. I need to create a report that has a Group Header that pulls certain data from the Detail section. It's something like this: +--Report---------------------------------------- |...
10
by: BBFrost | last post by:
We just recently moved one of our major c# apps from VS Net 2002 to VS Net 2003. At first things were looking ok, now problems are starting to appear. So far ... (1) ...
8
by: Andy Capon | last post by:
Hi There, We have a medium size project about 2000 source files and 700,000 lines of code, as you can imagine this takes some time to rebuild all. Now our problem is that we have a code...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
1
by: Sudhir | last post by:
I have created a dynamic datagrid and would like to sort the grid when I click the column name in the header. ----------------------------------------------- Private Sub btnSearch_Click(ByVal...
4
by: Christopher Ireland | last post by:
Hi all, I've got an app written under the v1.1 of the .Net framework and I'm now considering recompiling it under v2.0. Can I expect my app to run any faster? Are there any advantages to...
3
by: mansoorindia | last post by:
Is there any possibility to change the header code to access.mdb file like we use in dbase/fox wherein we change the header hex code and after change header codes, the file is not open his own...
56
by: valentin tihomirov | last post by:
{ int i = 2; } int i = 1; There is no 'i' defined in the 'parent' context from the moment of declaration on. So what is the problem? They tell us they pursue language simplicity. The rule "do...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.