Maestro
Maestro

Reputation: 9518

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?

Upvotes: 1

Views: 584

Answers (1)

Matthew Moss
Matthew Moss

Reputation: 1248

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

Upvotes: 5

Related Questions