cog1to / st-ligatures

Patches for ST (suckless terminal) that add support for ligatures drawing
53 stars 5 forks source link

gcc-11.3.0 error: complains about "features[]" being empty #25

Closed acid-bong closed 1 year ago

acid-bong commented 1 year ago

OS: Gentoo, all USE flags mentioned are set by default GCC: 11.3.0, USE="cxx fortran multilib nls nptl openmp pie sanitize ssp" glibc: 2.36, USE="multiarch multilib ssp stack-realign static-libs" harfbuzz: 5.3.1 (don't think it matters much, the main problem seems to be syntax) st: 0.9 patch used: alpha+scrollback_ringbuffer

The make output:

st build options:
CFLAGS  = -I/usr/X11R6/include  -I/usr/include/freetype2   -I/usr/include/freetype2   -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include  -DVERSION="0.9" -D_XOPEN_SOURCE=600  -O1
LDFLAGS = -L/usr/X11R6/lib -lm -lrt -lX11 -lutil -lXft  -lfontconfig -lfreetype   -lfreetype   -lharfbuzz
CC      = c99
cp config.def.h config.h
c99 -I/usr/X11R6/include  `pkg-config --cflags fontconfig`  `pkg-config --cflags freetype2`  `pkg-config --cflags
harfbuzz` -DVERSION=\"0.9\" -D_XOPEN_SOURCE=600  -O1 -c st.c
st.c: In function 'tnew':
st.c:1070:22: warning: ISO C forbids empty initializer braces [-Wpedantic]
 1070 |         term = (Term){};
      |                      ^
c99 -I/usr/X11R6/include  `pkg-config --cflags fontconfig`  `pkg-config --cflags freetype2`  `pkg-config --cflags
harfbuzz` -DVERSION=\"0.9\" -D_XOPEN_SOURCE=600  -O1 -c x.c
c99 -I/usr/X11R6/include  `pkg-config --cflags fontconfig`  `pkg-config --cflags freetype2`  `pkg-config --cflags
harfbuzz` -DVERSION=\"0.9\" -D_XOPEN_SOURCE=600  -O1 -c boxdraw.c
c99 -I/usr/X11R6/include  `pkg-config --cflags fontconfig`  `pkg-config --cflags freetype2`  `pkg-config --cflags
harfbuzz` -DVERSION=\"0.9\" -D_XOPEN_SOURCE=600  -O1 -c hb.c
hb.c:28:27: warning: ISO C forbids empty initializer braces [-Wpedantic]
   28 | hb_feature_t features[] = { };
      |                           ^
hb.c:28:14: error: zero or negative size array 'features'
   28 | hb_feature_t features[] = { };
      |              ^~~~~~~~
make: *** [Makefile:22: hb.o] Error 1

The complete build is hosted at sourcehut

Comparison:

cog1to commented 1 year ago

Most likely just Gentoo thing. I assume they made -Wpedantic turned on by default for their flavor of gcc.

C standard does indeed forbids empty arrays, but I can't come up with a clean way to make this thing comply with -Wpedantic, while keeping it simple and easy to modify. I think it's easier for you just to comment out mentions of features.

acid-bong commented 1 year ago

Finally decided to revisit the issue.

-pedantic is not in the flavour per se, but definitely in the c99 wrapper:

...
exec x86_64-pc-linux-gnu-gcc -std=c99 -pedantic -U_FORTIFY_SOURCE ${1+"$@"}
# the latter might be the result of using hardened profile

As i don't know how to rewrite the feature macro, for me the temporary solution would be CC = c99 -Wno-pedantic, which just disables that flag

cog1to commented 1 year ago

You don't really need to rewrite the macro, you can just comment out this line in hb.c:

hb_feature_t features[] = { };

and then replace its usage with NULL:

hb_shape(font, buffer, NULL, 0);
acid-bong commented 1 year ago

(I shoulda replied sooner) I immediately edited it like you said and it worked since. Cheers