project-repo / cagebreak

Cagebreak: A Wayland Tiling Compositor Inspired by Ratpoison
MIT License
286 stars 19 forks source link

2.0.0 fails to build on FreeBSD with Clang >= 15 #36

Closed jbeich closed 1 year ago

jbeich commented 1 year ago

reallocarray(3) is not in POSIX thus not visible with _POSIX_C_SOURCE. Linux cheats POSIX via _DEFAULT_SOURCE but on BSDs the cheat knob is different (__BSD_VISIBLE on DragonFly/FreeBSD/OpenBSD and _NETBSD_SOURCE on NetBSD).

$ cc --version
FreeBSD clang version 15.0.6 (https://github.com/llvm/llvm-project.git llvmorg-15.0.6-0-g088f33605d8a)
Target: x86_64-unknown-freebsd14.0
Thread model: posix
InstalledDir: /usr/bin
$ meson setup _build
$ meson compile -C _build
[...]
../cagebreak.c:197:11: warning: call to undeclared function 'reallocarray'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
                        line = reallocarray(line, line_length, sizeof(char));
                               ^
../cagebreak.c:197:9: error: incompatible integer to pointer conversion assigning to 'char *' from 'int' [-Wint-conversion]
                        line = reallocarray(line, line_length, sizeof(char));
                             ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Note, on Clang < 15 -Wint-conversion doesn't error out, so the implicit declaration of reallocarray sometimes leads to crashes.

jbeich commented 1 year ago

Fixed in 2.0.1.