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

Greg KH greg at kroah.com
Tue Aug 5 20:04:09 PDT 2014

On Tue, Aug 05, 2014 at 09:47:09PM -0500, Dan McGee wrote:
> On Tue, Aug 5, 2014 at 9:11 PM, Greg KH <greg at kroah.com> wrote:
>     On Tue, Aug 05, 2014 at 07:58:47PM -0500, Dan McGee 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.
>     Why not just fix MAX()?
> Mainly because 1) I'm not a preprocessor expert, and 2) this code is the only
> broken usage of MAX() and it was recently introduced.

But how will I, a non-clang-developer, know to use your special version
instead of the "normal" MAX() macro?

> I'm all for someone fixing this the "right" way if this is deemed incorrect,
> but right now one can't even compile on what most would consider a
> non-experimental C toolchain, and this was the quickest and easiest fix I could
> come up with.

I'd recommend fixing it "properly", or push back and fix clang's
extension definitions.

Oh and the systemd MAX() macro isn't typesafe, I'll work on fixing that
when I get a chance, it's messy as people haven't been all that careful
in some places...


greg k-h

More information about the systemd-devel mailing list