在Unix编译Dhrystone时出现错误。

3
我刚开始使用基准测试和makefile。我从以下链接下载了Dhrystone基准测试,试图编译它,但是遇到了奇怪的错误。我尝试解决它,但是一直没有成功。有人可以帮我运行dhrystone基准测试吗? 以下是我尝试编译的两种不同方式。但是两者都给出了相同的错误结果 :(
链接:http://fossies.org/unix/privat/old/dhrystone-2.1.tar.gz/ 尝试的编译命令如下:
gcc -g dhry.h dhry_1.c dhry_2.c -o dhrystonex

make all 

错误:

gcc -O -DTIMES           -DHZ=60                dhry_1.c dhry_2.c  -o gcc_dry2
dhry_1.c:31:18: warning: conflicting types for built-in function ‘malloc’ [enabled by default]
dhry_1.c:48:17: error: conflicting types for ‘times’
/usr/include/i386-linux-gnu/sys/times.h:49:16: note: previous declaration of ‘times’ was here
dhry_1.c: In function ‘main’:
dhry_1.c:98:3: warning: incompatible implicit declaration of built-in function ‘strcpy’ [enabled by default]
dhry_1.c:124:11: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
make: *** [gcc_dry2] Error 1
1个回答

6
请按照以下步骤进行更改。前面带有-的行表示您应该删除的行。前面带有+的行表示您应该添加的行。总共,您将替换两行(在它们之前加上//),并添加一行新的行(一个#include):
    diff -bup orig/dhry_1.c new/dhry_1.c
    --- orig/dhry_1.c       2012-03-30 11:30:41.984107303 -0700
    +++ new/dhry_1.c        2012-03-30 11:31:29.256002567 -0700
    @@ -28,7 +28,7 @@ char            Ch_1_Glob,
     int             Arr_1_Glob [50];
     int             Arr_2_Glob [50] [50];

    -extern char     *malloc ();
    +// extern char     *malloc ();
     Enumeration     Func_1 ();
       /* forward declaration necessary since Enumeration may not simply be int */

    @@ -45,7 +45,7 @@ Enumeration     Func_1 ();

     #ifdef TIMES
     struct tms      time_info;
    -extern  int     times ();
    +// extern  int     times ();
                                     /* see library function "times" */
     #define Too_Small_Time (2*HZ)
                                     /* Measurements should last at least about 2 seconds */
    diff -bup orig/dhry.h new/dhry.h
    --- orig/dhry.h 2012-03-30 11:30:41.984107303 -0700
    +++ new/dhry.h  2012-03-30 11:31:29.256002567 -0700
    @@ -392,6 +392,7 @@
     /* General definitions: */

     #include <stdio.h>
    +#include <string.h>
                                     /* for strcpy, strcmp */

     #define Null 0 

哦!太简单了!你在几秒钟内就完成了我的工作。我仍然不明白为什么我错过了这样一个简单的编译错误...无论如何,非常感谢。 - bobby
@sreeharivallu:现在是时候花2分钟时间为解决您问题的答案(http://i.imgur.com/uqJeW.png)点赞了,并且点赞其他帮助您的答案(http://i.imgur.com/kygEP.png)。祝大家好运。 - shellter

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接