You can save time by creating a complete image of your project with Insure++ when you begin the debugging process. Then as you find and fix errors, you can just recompile one or two files at a time with Insure++. This will cut down greatly on compilation time in comparison with recompiling every file every time you want to switch from a normal build to an Insure++ build or vice versa.

The makefile shown below builds a program consisting of two source files, func.c and main.c. Typing make would build main in the current directory, using the default settings in the makefile. However, all that is necessary to build a completely separate version of the program with Insure++ is a command similar to the following, where insure_debug is an example of a tree directory and should be changed as appropriate:

make CC=’insure cc’ TDIR=insure_debug

Alternatively, you can edit the makefile to redefine CC and TDIR each time you want to switch between a normal and an Insure++ build.

CC = cc
CFLAGS = -g
TDIR = .
OBJS = $(TDIR)/main.o $(TDIR)/func.o
$(TDIR)/main: $(OBJS)
         $(CC) $(CFLAGS) -o $(TDIR)/main $(OBJS)
$(TDIR)/main.o: main.c
         $(CC) $(CFLAGS) -o $(TDIR)/main.o -c main.c
$(TDIR)/func.o: func.c
         $(CC) $(CFLAGS) -o $(TDIR)/func.o -c func.c
clean:
         /bin/rm -rf $(TDIR)/*.o $(TDIR)/main

If you normally build libraries from your objects and do not explicitly add objects to your link line, you can do a similar trick by building a variable, such as TDIR into the object and library names.

CC = cc
CFLAGS = -g
TARGET =
OBJS = main$(TARGET).o
LIBS = libfunc$(TARGET).a
main$(TARGET): $(OBJS) $(LIBS)
         $(CC) $(CFLAGS) -o main$(TARGET) $(OBJS) $(LIBS)
libfunc$(TARGET).a: func$(TARGET).o
         ar ruv libfunc$(TARGET).a Func$(TARGET).o
main$(TARGET).o: main.c
         $(CC) $(CFLAGS) -o main$(TARGET).o -c main.c
func$(TARGET).o: func.c
         $(CC) $(CFLAGS) -o func$(TARGET).o -c func.c
clean:
/bin/rm -rf *$(TARGET).o main$(TARGET)\
                           libfunc$(TARGET).a

In this case, the following command would leave you with versions of your objects, libraries, and executable tagged with names ending in _ins:

make CC=’insure cc’ TARGET=_ins

  • No labels