On Tue, Feb 5, 2019 at 1:38 AM Rasmus Villemoes <li...@rasmusvillemoes.dk> wrote: > > On 05/02/2019 09.05, Masahiro Yamada wrote: > > On Mon, Feb 4, 2019 at 4:24 AM Rasmus Villemoes > > <li...@rasmusvillemoes.dk> wrote: > >> +#define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, > >> #expr) > >> +#define __static_assert(expr, msg, ...) _Static_assert(expr, "" msg "") > > > > What is the "" "" for? > > Good point. It's a leftover from when I had a fallback-implementation of > _Static_assert for gcc < 4.6, where I wanted to ensure that the second > argument was a string literal, even if my fallback implementation > ignored that argument. Now it's actually a little harmful, because
I had assumed it was for the "optional" part of the error message, since whether you pass a string error message or not, the C preprocessor should join them all together? > > foobar.c:5:34: error: expected string literal before ‘expected’ > static_assert(sizeof(long) == 8, expected 64 bit machine); Hopefully you'd put `expected` in double quotes? Note: I'm _very_ happy to see this being added. Once it's landed, I too can think of some places that it would work better than BUILD_BUG_ON(). -- Thanks, ~Nick Desaulniers