I’m trying to write a macro to create user-defined literals out of a regular string literals. The following two lines should create the token "foobar"_literal:
#define AS_LITERAL(TEXT) TEXT ## _literal
AS_LITERAL("foobar");
However, the pre-processor of GCC-4.7 reports the following error:
error: pasting ""foobar"" and "_literal" does not give a valid preprocessing token
How to do that correctly?
It works with an appropriately defined
operator "" _literal(using GCC 4.7 as well):