2014-10-29 78 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