【发布时间】:2014-06-11 12:29:33
【问题描述】:
builtin-stat.c: In function ‘abs_printout’:
builtin-stat.c:1023:5: error: incompatible type for argument 2 of ‘gzwrite’
gzwrite(trace_file, avg, sizeof(avg));
^
In file included from builtin.h:6:0,
from builtin-stat.c:45:
/usr/include/zlib.h:1341:21: note: expected ‘voidpc’ but argument is of type ‘double’
ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
什么是voidpc 类型?从来没有听说过。 zlib.h 告诉我它是 z_void。这是什么意思?我应该在这里打字吗?
警告:
CC builtin-stat.o
builtin-stat.c: In function ‘abs_printout’:
builtin-stat.c:1020:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
int written = gzwrite(trace_file, (void *) &avg, sizeof(avg));
^
builtin-stat.c:1024:9: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘double’ [-Wformat=]
fprintf(stderr, "Failed to write %d to file\n", avg);
^
builtin-stat.c:1026:13: warning: passing argument 1 of ‘fclose’ from incompatible pointer type [enabled by default]
fclose(trace_file);
^
In file included from util/util.h:45:0,
from builtin.h:4,
from builtin-stat.c:45:
/usr/include/stdio.h:237:12: note: expected ‘struct FILE *’ but argument is of type ‘gzFile’
extern int fclose (FILE *__stream);
^
builtin-stat.c:1029:5: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long unsigned int’ [-Wformat=]
printf("Passed %d bytes, wrote %d\n", sizeof avg, written);
【问题讨论】: