[ovs-dev] [PATCH] compiler: Use C11 build assertions with new enough GCC or Clang.

Ben Pfaff blp at ovn.org
Fri Mar 17 04:04:14 UTC 2017


On Thu, Mar 16, 2017 at 05:24:59PM -0700, Jarno Rajahalme wrote:
> LGTM with one question below,
> 
> Acked-by: Jarno Rajahalme <jarno at ovn.org>

Thanks!

> > On Mar 16, 2017, at 2:04 PM, Ben Pfaff <blp at ovn.org> wrote:
> > +#elif (__GNUC__ * 256 + __GNUC_MINOR__ >= 0x403 \
> > +       || __has_extension(c_static_assert))
> > +#define BUILD_ASSERT_DECL(EXPR) _Static_assert(EXPR, #EXPR)
> > +#define BUILD_ASSERT(EXPR) (void) ({ _Static_assert(EXPR, #EXPR); })
> 
> Curly braces in a macro is a GCC feature, so is it possible that a
> compiler has the “c_static_assert” extension but not this one? I see
> that __has_extension() is defined as 0 if it is not defined, so if it
> it only ever defined for GCC or compatible compiler, then this
> question is moot.

To the best of my knowledge, only Clang implements __has_extension.

OVS only really supports GCC, Clang, and MSVC, although adding support
for other compilers is probably not too hard if they're decent
compilers.  So I think we're probably OK.

I applied this to master.


More information about the dev mailing list