we*****@yahoo.com wrote in message
<11**********************@h48g2000cwc.googlegroups .com>...
>I need suggestion where I should look for. Why "make clean" can sovle
the problem, while it will not work if not "make clean", do I have
build env issue? or something funny here?
[OT]
Let's say you have three files in your project - A.h, A.cpp, Main.cpp:
[assume you are using an IDE that runs 'make' on a makefile.]
// A.h
int SomeFunc();
// A.cpp
int SomeFunc(){ return 50000 * 60000; }
// Main.cpp
#include A.h
int main(){
int Anumber = SomeFunc();
return 0;
}
Assume it compiles and runs.
Now you decide that SomeFunc() should return an long instead of an int, so
you change it:
// A.h
long SomeFunc();
// A.cpp
long SomeFunc(){ return 50000 * 60000; }
....and compile the project again. It compiles, but won't 'build'. What
happened?
The first time it took A.cpp and Main.cpp and produced A.o (or A.obj) and
Main.o and then 'linked' the two together to 'Main' (or 'Main.exe').
Then you changed A.cpp, and tried to build it. The 'make' re-built A.o, but
noticed that Main.cpp and Main.o had the SAME time/date, so, it did NOT
rebuild it! Then the 'linker' tried to match the 'int' call to SomeFunc()
[which now returns an long]. The linker pukes!!
Doing 'make clean' deletes ALL the *.o files so that ALL files are rebuilt
and linked.
MY explaination may not be correct or complete; but I hope it showed enough
for you to see why 'make clean' is needed (in this case, the compiler would
quit at the long to int problem, and never make it to the link stage.).
Does that clear up anything for you?
Since the subject is Off Topic in this NG, we can't discuss it much further,
you'll have to read your docs or ask in an NG specific to your
compiler/make/linker.
[/OT]
--
Bob R
POVrookie