Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/131.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 使用过时类的主_C++_Makefile - Fatal编程技术网

C++ 使用过时类的主

C++ 使用过时类的主,c++,makefile,C++,Makefile,我的main使用的类方法已经过时了。我已经更新了方法,将cout发送到终端,但是没有显示任何内容。我在方法调用之前和之后放置了一个cout,它们都被打印出来。这让我觉得我编错了 我已附上我的Makefile: RM = rm -f SRCPATH = . SRC = actors/actor.h controllers/AiController.h controllers/Controller.h \ controllers/PlayerController.h states/BrawlSta

我的main使用的类方法已经过时了。我已经更新了方法,将cout发送到终端,但是没有显示任何内容。我在方法调用之前和之后放置了一个cout,它们都被打印出来。这让我觉得我编错了

我已附上我的Makefile:

RM = rm -f
SRCPATH = .
SRC = actors/actor.h  controllers/AiController.h controllers/Controller.h \
controllers/PlayerController.h states/BrawlState.h states/DrinkState.h \
states/IdleState.h states/IStateCallback.h states/MineState.h \
states/SingState.h states/SleepState.h states/state.h states/statemachine.h \
resources/dynamicarray.h resources/hashmap.h resources/hashnode.h \
resources/heap.h resources/queue.h resources/stack.h resources/vector3d.h
TESTNAME = test
TESTSRC = main.cpp
#
retest: re test

clean:
    -$(RM) *.o
    -$(RM) *~
    -$(RM) \#*
    -$(RM) *.core
    -$(RM) *.gch

fclean: clean
    -$(RM) $(TESTNAME)

re: fclean

test: 
    g++ $(SRC) $(TESTSRC) -Wall -Werror -std=c++0x -o $(TESTNAME)

您需要使
test
目标依赖于所有源文件和头文件,以便在下次运行
make test
时,其中任何一个文件的更改都会触发重新编译:

test: $(TESTSRC) $(SRC)
    g++ $(SRC) $(TESTSRC) -Wall -Werror -std=c++0x -o $(TESTNAME)

你是只有头文件,还是也有
.cpp
文件?我只有头文件是因为它们是类。这实际上没有任何意义,但还行。您需要使
test
依赖于所有标题,加上
main.cpp
。对不对
test
没有依赖项。首先,给程序命名
test
是个糟糕的主意
test
是一个内置的shell,如果人们试图在没有路径的情况下运行它,就会非常困惑。第二,这个makefile不是很有用,因为它在任何更改时都会重新编译所有内容。重点是什么?您不妨编写一个shell脚本。这几天我经常看到这种事情,真是太疯狂了。