Search code examples
c++cvisual-c++coding-style

How to use symbols in a string?


This line will not compile in Visual C++

printf("x=%"PRIszu")\n",

Even though the symbol is defined:

#define PRIszu    "Iu"

I get the following error:

Error C3688 invalid literal suffix 'PRIszu'; literal operator or template 'operator ""PRIszu' not found

So how do I fix this print line to make use of the defined symbol?


Solution

  • Perhaps...?

    printf("x=%" PRIszu "\n", yourVar);
    

    I suspect you are using a C++11 compiler, which permits user-defined literals. See the answer here: Using macro with string fails on VC 2015