我将-g选项添加到makefile中,如下所示:
CFLAGS=-Wall -g
all:
cc hello.c -o hello
cc badprog.c -o badprog当我使用make编译时:
cc hello.c -o hello
cc badprog.c -o badprog我不认为-g选项here.The结果的valgrind --track-origins=yes ./badprog如下所示:
==14412== Conditional jump or move depends on uninitialised value(s)
==14412== at 0x4E7D665: _itoa_word (_itoa.c:179)
==14412== by 0x4E81B91: vfprintf (vfprintf.c:1654)
==14412== by 0x4E880A8: printf (printf.c:34)
==14412== by 0x400564: main (in /home/anr/Desktop/c programming/badprog)
==14412== Uninitialised value was created by a stack allocation
==14412== at 0x40052C: main (in /home/anr/Desktop/c programming/badprog)发布于 2013-11-24 02:48:36
因为编译命令中没有引用CFLAGS。将Makefile修改为:
CFLAGS=-Wall -g
all:
cc hello.c $(CFLAGS) -o hello
cc badprog.c $(CFLAGS) -o badproghttps://stackoverflow.com/questions/20170492
复制相似问题