现象描述 今天在编译tree-2.0.2的源码时报错如下: tree.c:668:3: error: ‘for’ loop initial declarations are only allowed in C99 mode for(int i=0; i < ipattern; i++) ^ tree.c:668:3: note: use option -std=c99 or -std=gnu99 to compile your code
[root@k8s-master tree-2.0.2]# make
gcc -O3 -pedantic -Wall -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o tree.o tree.c
In file included from tree.c:20:0:
tree.h:63:1: warning: C++ style comments are not allowed in ISO C90 [enabled by default]
// Start using PATH_MAX instead of the magic number 4096 everywhere.
^
tree.h:63:1: warning: (this will be reported only once per input file)[enabled by default]
tree.c:47:1: warning: C++ style comments are not allowed in ISO C90 [enabled by default]
//off_t (*listdir)(char *, int *, int *, u_long, dev_t)= unix_listdir;
^
tree.c:47:1: warning: (this will be reported only once per input file)[enabled by default]
tree.c: In function ‘main’:
tree.c:100:3: warning: ISO C90 forbids mixed declarations and code [-Wpedantic]
bool needfulltree;
^
tree.c:124:29: warning: ISO C90 forbids compound literals [-Wpedantic]
lc =(struct listingcalls){
^
tree.c:138:3: warning: ISO C90 forbids mixed declarations and code [-Wpedantic]
char *stddata_fd = getenv(ENV_STDDATA_FD);
^
tree.c:145:33: warning: ISO C90 forbids compound literals [-Wpedantic]
lc =(struct listingcalls){
^
tree.c:263:30: warning: ISO C90 forbids compound literals [-Wpedantic]
lc =(struct listingcalls){
^
tree.c:271:30: warning: ISO C90 forbids compound literals [-Wpedantic]
lc =(struct listingcalls){
^
tree.c:279:30: warning: ISO C90 forbids compound literals [-Wpedantic]
lc =(struct listingcalls){
^
tree.c: In function ‘usage’:
tree.c:659:2: warning: string length ‘3348’ is greater than the length ‘509’ ISO C90 compilers are required to support [-Woverlength-strings]" -- Options processing terminator.\n");
^
tree.c: In function ‘patignore’:
tree.c:668:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for(int i=0; i < ipattern; i++)
^
tree.c:668:3: note: use option -std=c99 or -std=gnu99 to compile your code
tree.c: In function ‘patinclude’:
tree.c:679:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for(int i=0; i < pattern; i++)
^
tree.c: In function ‘getinfo’:
tree.c:712:3: warning: ISO C90 forbids mixed declarations and code [-Wpedantic]
int isdir =(st.st_mode & S_IFMT)== S_IFDIR;
^
tree.c: In function ‘do_date’:
tree.c:1279:7: warning: ISO C90 does not support the ‘%e’ gnu_strftime format[-Wformat=]
strftime(buf,255,"%b %e %Y",tm);
^
tree.c:1281:7: warning: ISO C90 does not support the ‘%e’ gnu_strftime format[-Wformat=]
strftime(buf,255,"%b %e %R", tm);
^
tree.c:1281:7: warning: ISO C90 does not support the ‘%R’ gnu_strftime format[-Wformat=]
tree.c: In function ‘printit’:
tree.c:1304:2: warning: ISO C90 does not support the ‘%lc’ gnu_printf format[-Wformat=]if(iswprint(*tp)) fprintf(outfile,"%lc",(wint_t)*tp);
^
tree.c: In function ‘psize’:
tree.c:1351:59: warning: ISO C90 does not support ‘long long’ [-Wlong-long]}elsereturn sprintf(buf, sizeof(off_t)== sizeof(long long)? " %11lld":" %9lld", (long long int)size);
^
tree.c:1351:94: warning: ISO C90 does not support ‘long long’ [-Wlong-long]}elsereturn sprintf(buf, sizeof(off_t)== sizeof(long long)? " %11lld":" %9lld", (long long int)size);
^
tree.c:1351:3: warning: ISO C90 does not support the ‘ll’ gnu_printf length modifier [-Wformat=]}elsereturn sprintf(buf, sizeof(off_t)== sizeof(long long)? " %11lld":" %9lld", (long long int)size);
^
tree.c: In function ‘fillinfo’:
tree.c:1398:50: warning: ISO C90 does not support ‘long long’ [-Wlong-long]if(inodeflag) n += sprintf(buf," %7lld",(long long)ent->linode);
^
tree.c:1398:3: warning: ISO C90 does not support the ‘ll’ gnu_printf length modifier [-Wformat=]if(inodeflag) n += sprintf(buf," %7lld",(long long)ent->linode);
^
make: *** [tree.o] Error 1