This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

strstr.c:105:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode


Looking at the build logs I've also noticed this:

x86_64-jehanne-gcc
-B/home/giacomo/projects/Jehanne/repos/jehanne-test2/hacking/cross/pkgs/newlib/build/x86_64-jehanne/newlib/
-isystem /home/giacomo/projects/Jehanne/repos/jehanne-test2/hacking/cross/pkgs/newlib/build/x86_64-jehanne/newlib/targ-include
-isystem /home/giacomo/projects/Jehanne/repos/jehanne-test2/hacking/cross/pkgs/newlib/src/newlib/libc/include
-B/home/giacomo/projects/Jehanne/repos/jehanne-test2/hacking/cross/pkgs/newlib/build/x86_64-jehanne/libgloss/x86_64
-L/home/giacomo/projects/Jehanne/repos/jehanne-test2/hacking/cross/pkgs/newlib/build/x86_64-jehanne/libgloss/libnosys
-L/home/giacomo/projects/Jehanne/repos/jehanne-test2/hacking/cross/pkgs/newlib/src/libgloss/x86_64
   -I/home/giacomo/projects/Jehanne/repos/jehanne-test2/hacking/cross/pkgs/newlib/src/newlib/libc/sys/jehanne/include
-DPACKAGE_NAME=\"newlib\" -DPACKAGE_TARNAME=\"newlib\"
-DPACKAGE_VERSION=\"3.1.0\" -DPACKAGE_STRING=\"newlib\ 3.1.0\"
-DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -I.
-Isrc/newlib/libc/string -fno-builtin -DREENTRANT_SYSCALLS_PROVIDED
-DMALLOC_PROVIDED -DSIGNAL_PROVIDED -D_NO_GETLOGIN -D_NO_GETCWD
-D_NO_GETPASS -D_NO_GETUT -D_NO_PWRITE -D_NO_PREAD -DHAVE_FCNTL
-fno-omit-frame-pointer -DHAVE_INIT_FINI      -g -gdwarf-2 -ggdb -O2
-c -o lib_a-strstr.o `test -f 'strstr.c' || echo
'src/newlib/libc/string/'`strstr.c
src/newlib/libc/string/strstr.c: In function ‘strstr2’:
src/newlib/libc/string/strstr.c:105:3: error: ‘for’ loop initial
declarations are only allowed in C99 or C11 mode
   for (int c = hs[0]; h1 != h2 && c != 0; c = *++hs)
   ^
src/newlib/libc/string/strstr.c:105:3: note: use option -std=c99,
-std=gnu99, -std=c11 or -std=gnu11 to compile your code
src/newlib/libc/string/strstr.c: In function ‘strstr3’:
src/newlib/libc/string/strstr.c:115:3: error: ‘for’ loop initial
declarations are only allowed in C99 or C11 mode
   for (int c = hs[0]; h1 != h2 && c != 0; c = *++hs)
   ^
src/newlib/libc/string/strstr.c: In function ‘strstr4’:
src/newlib/libc/string/strstr.c:125:3: error: ‘for’ loop initial
declarations are only allowed in C99 or C11 mode
   for (int c = hs[0]; c != 0 && h1 != h2; c = *++hs)
   ^
src/newlib/libc/string/strstr.c: In function ‘strstr’:
src/newlib/libc/string/strstr.c:173:7: error: ‘for’ loop initial
declarations are only allowed in C99 or C11 mode
       for (int i = 0; i < ne_len; i++)
       ^
Makefile:851: recipe for target 'lib_a-strstr.o' failed

I guess this use of variable initialization in the for loop works fine
in linux, in cygwin and in amdgcn but it's a bit annoying in common
code like strstr.c

It also occurs in

newlib/libc/locale/freelocale.c:49
newlib/libc/string/memmem.c:149

Is it possible to move the counter declaration outside the loop?


Giacomo


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]