Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to properly use `__attribute__((format (printf, x, y)))` for C11 U"unicode literals"?

I'm porting an application from using char* for everything and everywhere to using UCS4 as it's internal Unicode representation. I use C11's U"unicode literals" for defining strings, which expand to arrays of char32_t, which are uint32_t essentially.

Problem is with properly annotating printf-like functions. As "format" is no longer char*, compiler refuses to compile it further, as well it won't be happy with char32_t * instead of char * for %s format, I suppose.

I don't depend on stdlib *printf family at all, so formatting is done purely by mine implementation.

What is correct solution for this, other than just disable this attribute altogether?

like image 675
toriningen Avatar asked Nov 10 '22 23:11

toriningen


1 Answers

There is currently no way to do this in GCC. It is a known bug, see GCC bug 64862

like image 153
Tom Tromey Avatar answered Nov 14 '22 22:11

Tom Tromey