On Fri, Aug 15, 2014 at 12:35 PM, David Herrmann <dh.herrm...@gmail.com> wrote: > Hi > > On Fri, Aug 15, 2014 at 12:29 PM, Thomas H.P. Andersen <pho...@gmail.com> > wrote: >> On Fri, Aug 15, 2014 at 11:49 AM, David Herrmann <dh.herrm...@gmail.com> >> wrote: >>> Thanks for trying! >>> >>> Result is as I expected. Evaluation takes place _after_ validating >>> compile-time constants, and thus __builtin_constant_p in combination >>> with ?: will not work if not both cases are constant. Maybe it works >>> with __builtin_choose_expr()? >>> >>> Can you try the attached patch? >> >> This patch works. It also needs the change to do the calculation to a >> seperate line. Also only if size is const, like so: >> const size_t size = MAX(sizeof(struct in_pktinfo), sizeof(struct >> in6_pktinfo)); > > Again, thanks for trying it out!
no problem. I have inserted the relevant error messages for the two non-working cases. > I don't understand your comment, though. You're saying this works: > > const size_t size = MAX(...); > uint8_t buffer[CMSG_SPACE(size) +...]; > > ...but this doesn't work: > > uint8_t buffer[CMSG_SPACE(MAX(...)) +...]; src/resolve/resolved-dns-stream.c:67: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))) ^ > ...and this doesn't work either (mind the dropped 'const'): > > size_t size = MAX(...); > uint8_t buffer[CMSG_SPACE(size) +...]; src/resolve/resolved-dns-stream.c:68:25: error: fields must have a constant size: 'variable length array in structure' extension will never be supported uint8_t buffer[CMSG_SPACE(size) ^ > Hm. This is weird. Maybe CMSG_SPACE does something weird. I'll see. > David _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel