C11's static_assert
Stuart Swales (8827) 1326 posts |
Helpful, yes. But shouldn’t I be able to concatenate string literals (like everywhere else) for the message to be output? (Like I need to be able to do for some of my checking macros)
just errors with ‘oh’ on Norcroft cc5.91 whereas clang, gcc, MSVC are fine (see Compiler Explorer). |
Stuart Swales (8827) 1326 posts |
Oh hang on, it gets verse… It doesn’t like being placed at the end of a block.
"Serious Error: <command> expected but found '}'" |
Paolo Fabio Zaino (28) 1821 posts |
Yes: String Literals ... Semantics 4 In translation phase 6, the multibyte character sequences specified by any sequence of adjacent character and wide string literal tokens are concatenated into a single multibyte character sequence. If any of the tokens are wide string literal tokens, the resulting multibyte character sequence is treated as a wide string literal; otherwise, it is treated as a character string literal. The standard also provides some example (excerpt): EXAMPLE This pair of adjacent character string literals "\x12" "3" produces a single character string literal containing the two characters whose values are '\x12' and '3', because escape sequences are converted into single members of the execution character set just prior to adjacent string literal concatenation. and printf("x" "1" "= %d, x" "2" "= %s", x1, x2); after concatenation printf("x1= %d, x2= %s", x1, x2); |
Stuart Swales (8827) 1326 posts |
Indeedy. So why, he muses, is their processing in |
Paolo Fabio Zaino (28) 1821 posts |
humm, this works however, so not sure what is going on with your issue:
|
Paolo Fabio Zaino (28) 1821 posts |
either that or maybe it’s a macro? (no idea tbh, haven’t checked, so guessing) |