[systemd-devel] [PATCH] Fix compilation under clang/LLVM

Lennart Poettering lennart at poettering.net
Wed Aug 13 11:58:48 PDT 2014

On Tue, 05.08.14 19:58, Dan McGee (dan at archlinux.org) wrote:

> Compilation is failing because we are doing something not allowed by the
> language spec, but OK by GCC extensions in our MAX() macro.
> src/resolve/resolved-manager.c:759:43: error: non-const static data member must be initialized out of line
>                 uint8_t buffer[CMSG_SPACE(MAX(sizeof(struct in_pktinfo), sizeof(struct in6_pktinfo)))
>                                           ^
> Add a new constant that does this in a way both compilers are OK with,
> since we know all factors in the size computation are static.

I'd prefer if we could make MAX() just do the right thing in all

Hmm, this sounds like somethign we can fix with __builtin_constant_p()

See https://gcc.gnu.org/onlinedocs/gcc-4.3.3/gcc/Other-Builtins.html

I am pretty sure LLVM supports that, no?

Would be happy to take a patch that makes use of that...


Lennart Poettering, Red Hat

More information about the systemd-devel mailing list