Click to See Complete Forum and Search --> : No need to compile?
Wynd
Jun 6th, 2001, 11:12 PM
I have a class in a separate .h file that I never change. Is there a way to only compile this once and not have to do it again? Or is this automatically done for me and I made a pointless post? (Visual C++ 6)
kovan
Jun 7th, 2001, 02:22 AM
depands on what compiler your using
i use vc++
when i compile a project
it skipps over everything i havent changed since last compile time
parksie
Jun 7th, 2001, 03:30 AM
If you put it into a .h/.cpp combination then it will only compile it once. If it's in a header, it will compile it every time.
TadaTensai
Jun 10th, 2001, 01:25 PM
The make program uses a makefile to compile. It only compiles what has changed. And to all of you who use Visual C++, Learn it the hard way! With GCC/G++!
parksie
Jun 10th, 2001, 01:33 PM
Ah, but no ;)
If you #include "myheader.h" into mysource.cpp, then if myheader.h changes mysource.cpp is recompiled. If you have the class in myheader.h as myclass.h/myclass.cpp and you change myclass.cpp, only that file is recompiled and not mysource.cpp
Wynd
Jun 10th, 2001, 03:37 PM
:confused:
I only have two files, we'll say class.h and source.cpp. If i change source.cpp and not class.h, will class.h still be compiled?
parksie
Jun 10th, 2001, 03:58 PM
Indirectly, yes. Because class.h is included directly into source.cpp by the preprocessor, compiling source.cpp requires the contents of class.h to be compiled.
Wynd
Jun 10th, 2001, 04:44 PM
Ok. Is there a way to not have to compile it?
parksie
Jun 10th, 2001, 04:47 PM
Yes. The code sections of the .h file should be split into a .cpp file (the implementation of a class).
MyClass.h = contains definition of the class and its members
MyClass.cpp = contains implementation of the class, needs compiling
main.cpp = includes MyClass.h, if MyClass.h changes then main.cpp is recompiled. If MyClass.cpp changes then MyClass.cpp is recompiled but not main.cpp. If main.cpp is changed MyClass.cpp is not recompiled.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.