Quote:
|
Originally Posted by ta0kira
Rather than commenting out the #include, go into the header and comment out the entire header. This will cause compiler errors everywhere something that was declared in the .h is used. Commenting out the #include would only work on that particular source or header, whereas manipulating the actual originating document will take care of everything that #include's it. Linker errors should only be caused by .c/pp files unless you are using templates.
ta0kira
|
Thanks I will try that method.
I made a little program to test this and it works the same way. If I comment out the include it still works. This must generate a lot of bugs since one migth "forget" some heders and the when someone else tries to compile the source they should get errors. But offcourse Im not shore about this. Maybe its the makefile thats the problem.
the main.c file:
/*#include "a.h"*/
int main(int argc, char *argv[])
{
printf("a");
afunc();
printf("c");
return -1;
}
the a.c file:
void afunc()
{
printf("b");
}
the a.h file:
void afunc();
and my makefile (this one is an overkill but I wanted to test this one since I use it for my application)
CC = gcc
CFLAGS = -O2 -g -O2 -ansi -I/usr/X11R6/include -I/usr/X11R6/include -I/usr/include/freetype2 -I/usr/include/freetype2/freetype2 -I/usr/include/freetype2/freetype2/config -I/usr/X11R6/include `pkg-config gtk+-2.0 --cflags`
LDFLAGS = -L/usr/X11R6/lib -lX11 -lpng -lXpm -lXinerama -L/usr/X11R6/lib -lXft -lX11 -L/usr/lib -lfreetype -lfontconfig -L/usr/X11R6/lib -lXrender -lXext `pkg-config gtk+-2.0 --libs`
VERSION = 1.4
BINDIR = /usr/local/bin
GTK = `pkg-config gtk+-2.0 --cflags --libs`
VPATH=.

s
OBJECTS = a.o main.o
EXE = aprog
.SUFFIXES: .o .h .c
all: $(EXE)
install: all
strip $(EXE)
install -d $(BINDIR)
install $(EXE) $(BINDIR)/$(EXE)
depend:
makedepend -Ym *.c
$(EXE): $(OBJECTS)
$(CC) -o $(EXE) $(OBJECTS) $(LDFLAGS)
help.o: help.c
$(CC) -c $(CFLAGS) -DVERSION=\"$(VERSION)\" help.c
.c.o: $<
$(CC) -c $(CFLAGS) $<
clean:
rm -f $(OBJECTS) $(EXE) core