On Fri, Aug 15, 2014 at 10:55:57AM +0200, David Herrmann wrote: > Hi > > On Thu, Aug 14, 2014 at 8:07 PM, Lennart Poettering > <lenn...@poettering.net> wrote: > > On Fri, 18.07.14 16:02, Thomas H.P. Andersen (pho...@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... > > > > http://lists.freedesktop.org/archives/systemd-devel/2014-August/021912.html > > Hm, I don't know whether that works. See the description here: > https://gcc.gnu.org/onlinedocs/gcc-4.3.3/gcc/Other-Builtins.html > > What you propose is something like my attached patch, I guess? Along > the lines of: > (__builtin_constant_p(A) && __builtin_constant_p(B)) ? > ((A) > (B) ? (A) : (B)) : > ({ ....OLD_MAX.... }) > > Thing is, the ELSE case is not considered a compile-time constant by > LLVM. Therefore, the whole expression is not considered a compile-time > constant. I don't know whether conditions with __builtin_constant_p() > are evaluated at the parser-step. The GCC example replaces the ELSE > case with -1, effectively making both compile-time constants. Sorry I didn't follow the thread, but:
Actually and IIRC it is more complicated, __builtin_constant_p() can be computed during the SSA (optimization) passes on the GIMPLE form of the code... so it depends on the code and parameters passed to __builitin_constant_p(), not only preprocessor constants. https://gcc.gnu.org/onlinedocs/gccint/Tree-SSA.html -- Djalal Harouni http://opendz.org _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel