munificent / craftinginterpreters

Repository for the book "Crafting Interpreters"
http://www.craftinginterpreters.com/
Other
8.87k stars 1.04k forks source link

Make error #1079

Open shawnxbc opened 2 years ago

shawnxbc commented 2 years ago

Anybody can help?

make[1]: Entering directory '/home/shawn/download/craftinginterpreters'
      cc c/vm.c                                   -std=c99 -Wall -Wextra -Werror -Wno-unused-parameter -O3 -flto
      cc build/clox                               -std=c99 -Wall -Wextra -Werror -Wno-unused-parameter -O3 -flto
In function ‘concatenate’,
    inlined from ‘run’ at c/vm.c:656:11:
c/vm.c:384:17: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
  384 |   chars[length] = '\0';
      |                 ^
danaugrs commented 2 years ago

This is a warning, but the project is being compiled with -Werror which causes the compiler to treats warnings as errors. To get around this, open util/c.make and make the below change to ignore all warnings:

-CFLAGS += -Wall -Wextra -Werror -Wno-unused-parameter
+CFLAGS += -w
ThomasPDye commented 2 years ago

better to just disable that one warning though:

CFLAGS += -Wall -Wextra -Werror -Wno-unused-parameter -Wno-stringop-overflow