Anyways, we're given the following Makefile:
- Code: Select all
-include montype
CXX = u++
CXXFLAGS = -g -Wall -Wno-unused-label -DVOTERTYPE_$(TYPE)
OBJECTS = printer.o voter.o tallyVotes.o driver.o
EXEC = vote
ifeq ($(MONTYPE),$(TYPE))
$(EXEC) : $(OBJECTS)
$(CXX) $(CXXFLAGS) $(OBJECTS) -o $@
else
ifeq ($(TYPE),)
$(EXEC) : $(OBJECTS)
$(CXX) $(CXXFLAGS) $(OBJECTS) -o $@
else
.PHONY : $(EXEC)
$(EXEC) :
rm -f montype
touch tallyVotes.h
$(MAKE) TYPE=$(TYPE)
endif
endif
montype :
echo "MONTYPE:=$(TYPE)" > montype
tallyVotes.o : tallyVotes.h printer.h voter.h tallyVotes$(TYPE).cc
$(CXX) $(CXXFLAGS) -c tallyVotes$(TYPE).cc -o tallyVotes.o
tallyVotesAUTO.cc : AutomaticSignal.h
printer.o : printer.h voter.h
voter.o : voter.h printer.h tallyVotes.h
driver.o : printer.h voter.h tallyVotes.h
clean :
rm -f $(OBJECTS) $(EXEC) montype
By reading this, I've extracted the following file names that I have created and added the given code to already:
AutomaticSignal.h
driver.cc
printer.h
printer.cc
tallyVotes.h
tallyVotesAUTO.cc
tallyVotesEXT.cc
tallyVotesINT.cc
tallyVotesSEM.cc
voter.h
voter.cc
Here's the problem: Printer requires an enum from Voter in its header. So I include "voter.h." Voter requires Printer, so I create a forward declaration. It might work if I create a forward declaration for the enum which is in another class, but I don't know how to do that.
When I start working on the source (.cc) for Voter, it says: "invalid use of undefined type 'struct Printer' ". Which implies (to me) that I have to include printer.h in voter.cc. But if I do that, I get a redeclaration of class Voter error.
I know that I'm leaving out a lot of details, especially the interfaces for the classes that I'm trying to compile with. I'm trying to general the problem without providing too many details.
Any help is greatly appreciated.

