I am trying to create a macro definition that can emit C ++ or Objective-C depending on the context, but cannot easily build an NSString inside a macro. The C ++ version is simple because it uses regular strings, but creating what emits an NSString turns out to be difficult:
#define FOO(x) bar(@##x)
The intended result is to convert the string argument to an NSString argument by prefixing with @
:
FOO("x") // => bar(@"x")
Instead, I get an error that prevents compilation:
Pasting formed '@"x"', an invalid preprocessing token
source share