[systemd-devel] compile with clang broken

Lennart Poettering lennart at poettering.net
Thu Aug 14 11:07:44 PDT 2014

On Fri, 18.07.14 16:02, Thomas H.P. Andersen (phomes at gmail.com) wrote:

> 1716f6dcf54d4c181c2e2558e3d5414f54c8d9ca (resolved: add LLMNR support
> for looking up names) broke the build on clang.
> src/resolve/resolved-manager.c:553: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)))
> Moving the MAX(...) to a separate line fixes that problem but another
> error then happens:
> src/resolve/resolved-manager.c:554:25: error: fields must have a
> constant size: 'variable length array in structure' extension will
> never be supported
> uint8_t buffer[CMSG_SPACE(size)
> We have encountered the same problem before and Lennart was able to
> write the code in a different way. Would this be possible here too?

My sugegstion here would be to maybe rewrite the MAX() macro to use
__builtin_constant_p() so that it becomes constant if the params are
constant, and only uses code block when it isn't. Or so...



Lennart Poettering, Red Hat

More information about the systemd-devel mailing list