Skip to contentSkip to conversation

nbd/003: fix compiling error with gcc version 4.8.5

PATCH Applied Yi Zhang 2 participants 2 messages Feb 20, 2020 – Mar 4, 2020 Block layer

lore
Share & tools
lore

Yi Zhang

author
#0 lore raw

PATCH 1/1 nbd/003: fix compiling error with gcc version 4.8.5

cc -O2 -Wall -Wshadow -o mount_clear_sock mount_clear_sock.c
mount_clear_sock.c: In function ‘main’:
mount_clear_sock.c:39:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (int i = 0; i < loops; i++) {
^
mount_clear_sock.c:39:2: note: use option -std=c99 or -std=gnu99 to compile your code

---
 src/mount_clear_sock.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
src/mount_clear_sock.c +2 -2
index 4030a4a..984395e 100644
@@ -18,7 +18,7 @@
 int main(int argc, char **argv)
 {
 	const char *mountpoint, *dev, *fstype;
-	int loops, fd;
+	int loops, fd, i;
 
 	if (argc != 5) {
 		fprintf(stderr, "usage: %s DEV MOUNTPOINT FSTYPE LOOPS", argv[0]);
@@ -36,7 +36,7 @@ int main(int argc, char **argv)
 		return EXIT_FAILURE;
 	}
 
-	for (int i = 0; i < loops; i++) {
+	for (i = 0; i < loops; i++) {
 		pid_t mount_pid, clear_sock_pid;
 		int wstatus;
 
Signature · 1 line
2.21.0
#1 lore raw
Quoted 8 lines · Yi Zhang

cc -O2 -Wall -Wshadow -o mount_clear_sock mount_clear_sock.c
mount_clear_sock.c: In function ‘main’:
mount_clear_sock.c:39:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (int i = 0; i < loops; i++) {
^
mount_clear_sock.c:39:2: note: use option -std=c99 or -std=gnu99 to compile your code

Thanks, applied.