Thread (7 messages) 7 messages, 3 authors, 2015-11-30

Re: [iproute PATCH RFC] libnetlink: introduce DECLARE_NLREQ

From: Phil Sutter <phil@nwl.cc>
Date: 2015-11-26 14:00:04

On Thu, Nov 26, 2015 at 02:56:30PM +0100, Hannes Frederic Sowa wrote:
quoted
+#define DECLARE_NLREQ(name, hdrname, payload, tailroom)                       \
+	struct {                                                              \
+		struct nlmsghdr hdrname;                                      \
+		payload;                                                      \
+		char __b[tailroom] __attribute__((aligned(NLMSG_ALIGNTO)));   \
+	} name = { .hdrname = {                                               \
+		.nlmsg_len = (unsigned long)&name.__b - (unsigned long)&name, \
offsetof(typeof(name), __b) ?
Ah, thanks! I already considered offsetof(), but the fact it needs a
type name and the declared struct is anonymous appeared unsolvable to
me. Good to know typeof() can be used this way!

Thanks, Phil
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help