[Dev-C++] more on Dev-C++ 4.9.3.0 beta and perfect dependency
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Luigi S. <gi...@li...> - 2002-05-15 13:07:51
|
Hello Hongli Lai
At 21:15 14/05/02 +0200, Hongli Lai wrote:
>On Tue, 2002-05-14 at 18:15, Luigi Santillo wrote:
> > Hello list,
> >
> > I have only limited experience, so probably I'm missing something.
> >
> > I'm wondering how does Dev-C++ 4.9.3.0 find out that main.c should be
> > recompiled, when one changes something in main.h.
> >
> > Anyway I tried to do some test, and the "perfect dependency" idea,
> seems to
> > be not working, also I've given a look at the makefile (named
> > "makefile.win") and did see the name of no header file (that is, no ".h"
> > file) anywhere.
> >
>
>Dev-C++ executes "gcc -MM main.c" and put the output of that into the
>Makefile, so that make will handle dependencies.
>However, if the output of gcc -MM contains error messages, it's output
>will be ignored.
>
>You will also have to #include "main.h" into your main.c in order to
>make this work.
Thanks for your explanation. It is very clear.
Here are the steps I followed when doing my simple testing of the new
dependency generation feature.
1. The code. Instead of using main.c and main.h I've used: hello.c (main
source), print.h and print.c
hello.c print.h print.c
------- ------- -------
#include "print.h" #ifndef print_h #include <stdio.h>
int #define print_h #include "print.h"
main() void
{ void print(const char* s)
print("Hello world!"); print(const char *s); {
return 0; puts(s);
} #endif }
2. The compiler settings. I suppose the relevant item, here, is:
Tools->Compiler Options->Code Generation/Optimizations->Makefile generation->
"use fast but imperfect dependency generation".
Well, I've left the box not checked (which is the default when installing
the binary version of beta3); so I expect dependencies to be "slow but
perfect".
3. The project. I chose: File->New->Project->Basic->Console Application.
Also I selected "C project". Then named the project "test" and the project
file "test" (so that test.dev was created). Finally I removed the default
"main.c" file and added the 3 files hello.c, print.c and print.h.
When I compiled the project (using the Compile button) here is the
makefile.win generated:
makefile.win
------------
# Project: test
# Makefile created by Dev-C++ 4.9.3.0
CC = gcc.exe
WINDRES = windres.exe
RES =
OBJ = print.o hello.o $(RES)
LIBS = -L"c:\mingw\lib"
INCS = -I"c:\mingw\include"
BIN = test.exe
CFLAGS = $(INCS)-ansi -fexceptions -g3
.PHONY: clean
all: test.exe
clean:
rm -f $(OBJ) $(BIN)
$(BIN): $(OBJ)
$(CC) $(OBJ) -o $(BIN) $(RES) $(LIBS) $(CFLAGS)
print.o: print.c
$(CC) -c print.c -o print.o $(CFLAGS)
hello.o: hello.c
$(CC) -c hello.c -o hello.o $(CFLAGS)
As one can see, print.o depends only on print.c (print.h is missing), the
same is true of hello.o.
In case it can be of help, I'm using MinGW gcc shipped with stable Dev-C++
4.0, that is, the command: "gcc -v" prints "gcc version 2.95.2 19991024
(release)" and the command "gcc -MM print.c" works as you explained (I mean
there is no error, and it prints: "print.o: print.c print.h").
> > Finally I see no reason why the linker is called each time one clicks on
> > the compile button, even if no object file was updated (because no source
> > file did actually change) by the compiler: clearly this action is
> superfluous.
> >
>
>There's no reason to click on Compile if everything is already compiled
>anyway.
That is right. But I was testing :)
>The only reason I can think of is because the user wants to relink the
>app, that's why I made Dev-C++ behave like that.
I do not agree with you for this reason: if I use the program "make" and
try to make an already up-to-date program (that is, I type "make all -f
makefile.win"), "make" answers something like: "nothing needed to be done
for all"; it does not relink the program. I expected the same kind of
behavior when clicking "Compile" from Dev-C++.
Thanks again for your time.
Regards
--
Luigi
gi...@li...
|