2014-10-29 81 views
0

我正在一个malloc实验室程序,我需要找到效用和吞吐量的性能指标。我能够获得输出效率,但第一次执行时有一个问题。内存分配第一次在终端上编译错误

我给出了特定的一组文件,其中包括跟踪和其他文件,当我试图运行该程序第一次它显示错误,但是当我运行相同的代码相同的命令第二次多次我不是得到错误和输出是好的?为什么它在第一次运行时显示错误?在malloc中分配内存或执行操作有什么问题吗?

的命令,第一时间误差如下,

enter code here 
@ubuntu:$ make 
当我运行此我第一次收到错误是如下

enter code here 
gcc -Wall -O2 -m32 -c -o mdriver.o mdriver.c 
mdriver.c: In function ‘remove_range’: 
mdriver.c:438:9: warning: variable ‘size’ set but not used [-Wunused-but-set-variable] 
int size; 
    ^
mdriver.c: In function ‘read_trace’: 
mdriver.c:498:11: warning: ignoring return value of ‘fscanf’, declared with attribute warn_unused_result [-Wunused-result] 
fscanf(tracefile, "%d", &(trace->sugg_heapsize)); /* not used */ 
    ^
mdriver.c:499:11: warning: ignoring return value of ‘fscanf’, declared with attribute warn_unused_result [-Wunused-result] 
fscanf(tracefile, "%d", &(trace->num_ids));  
    ^
mdriver.c:500:11: warning: ignoring return value of ‘fscanf’, declared with attribute warn_unused_result [-Wunused-result] 
fscanf(tracefile, "%d", &(trace->num_ops));  
    ^
mdriver.c:501:11: warning: ignoring return value of ‘fscanf’, declared with attribute warn_unused_result [-Wunused-result] 
fscanf(tracefile, "%d", &(trace->weight));  /* not used */ 
    ^
mdriver.c:524:12: warning: ignoring return value of ‘fscanf’, declared with attribute warn_unused_result [-Wunused-result] 
fscanf(tracefile, "%u %u", &index, &size); 
     ^
mdriver.c:531:12: warning: ignoring return value of ‘fscanf’, declared with attribute warn_unused_result [-Wunused-result] 
fscanf(tracefile, "%u %u", &index, &size); 
     ^
mdriver.c:538:12: warning: ignoring return value of ‘fscanf’, declared with attribute warn_unused_result [-Wunused-result] 
fscanf(tracefile, "%ud", &index); 
     ^
gcc -Wall -O2 -m32 -c -o mm.o mm.c 
mm.c:780:13: warning: ‘mm_check’ defined but not used [-Wunused-function] 
static int mm_check(void) 
     ^
gcc -Wall -O2 -m32 -c -o memlib.o memlib.c 
gcc -Wall -O2 -m32 -c -o fsecs.o fsecs.c 
gcc -Wall -O2 -m32 -c -o fcyc.o fcyc.c 
gcc -Wall -O2 -m32 -c -o clock.o clock.c 
gcc -Wall -O2 -m32 -c -o ftimer.o ftimer.c 
gcc -Wall -O2 -m32 -o mdriver mdriver.o mm.o memlib.o fsecs.o fcyc.o clock.o ftimer.o 

我再次

运行相同的命令
enter code here 
@ubuntu:$ make 
make: `mdriver' is up to date. 

现在,然后它显示没有错误,之后,如果我用所需的逗号运行该程序nds它工作得很好,但它第一次显示错误?

+0

您有两种选择:(a)修复产生警告的代码,(b)禁用警告。如果你选择(b)准备承担后果:) – 2014-10-29 02:36:17

回答

0

你的来源没有错误。有很多警告。对象和可执行文件将被生成,即使源有警告。在makefile中,如果时间戳保持不变,则不会重新编译这些文件。

欲了解更多了解,请在您的源代码中安装一些编译错误,并一次又一次运行make命令,然后您就可以了解其差异。

+0

错误来自我的教授给出的一个名为mdriver.c的文件,我不必修改它,事情是我真的很困惑如何摆脱这些警告!我试图改变文件中的东西,但它并没有帮助我! – Dvlop 2014-10-29 01:19:24

+0

@Dvlop试试make -s。它将超过印刷品。然后分享错误消息。截至目前,我无法在您的发布中找到错误消息。尝试简化您的问题并重新发布。 – 2014-10-29 02:05:41