Work with typedef u8 to use C ++ 11 u8 string literal

I would like to use the new C ++ u8 string literal prefix ( reference ).

However, the code base I already use typedefs u8 for an unsigned char. I cannot practically move the headers around or #undef around them.

How can I get around this?

+4
source share
1 answer

It doesn't matter what u8was defined as a macro. A string literal, regardless of whether it has an encoding prefix, is the only preprocessor token. The prefix u8will not be macro-shot. Appendix C has an example demonstrating this:

#define u8 "abc"
const char *s = u8"def";  // Previously "abcdef", now "def"
+12
source

Source: https://habr.com/ru/post/1694210/


All Articles