kvm-hello-world icon indicating copy to clipboard operation
kvm-hello-world copied to clipboard

Question about -Werror in makefile

Open wanghaEMQ opened this issue 1 year ago • 0 comments

On some platforms. The compiler may check the array-bounds and see this line as an error.

cc -Wall -Wextra -Werror -O2 -m32 -ffreestanding -fno-pic -c -o guest32.o guest.c
guest.c: In function ‘_start’:
guest.c:17:9: error: array subscript 0 is outside array bounds of ‘long int[0]’ [-Werror=array-bounds=]
   17 |         *(long *) 0x400 = 42;
      |         ^~~~~~~~~~~~~~~
cc1: note: source object is likely at address zero

Removing the -Werror in makefile will fix it.

--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-CFLAGS = -Wall -Wextra -Werror -O2
+CFLAGS = -Wall -Wextra -O2

wanghaEMQ avatar Sep 06 '23 06:09 wanghaEMQ