lkml.org 
[lkml]   [2017]   [May]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] kernel.h: handle pointers to arrays better in container_of()
On Tue, May 23, 2017 at 11:32:02AM +0100, Ian Abbott wrote:

> > #define container_of(ptr, type, member) ( \
> > _Static_assert(__builtin_types_compatible_p( \
> > typeof(*ptr), typeof( ((type *)0)->member )), "WUT"), \
> > ((type *)((char *)(ptr) - offsetof(type, member))); \
> > )
>
> It's a fine suggestion (if more parentheses are added), but _Static_assert
> is a C11 feature, and I thought the kernel was using gnu89 (unless it's been
> updated since).

We have BUILD_BUG_ON() that should be similar in functionality.

\
 
 \ /
  Last update: 2017-05-23 13:24    [W:0.059 / U:0.152 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site