0

I want to transform

void func(

into

void _func(

I tried this:

#define void\ func( void _func(

but I get an error:

test.c(1): error C2008: '\': unexpected in macro definition

Is this even possible?

bolov
  • 72,283
  • 15
  • 145
  • 224
hacksoi
  • 1,301
  • 13
  • 23
  • Nope, not possible. Can be done with a good text editor. – user3386109 Jul 31 '18 at 17:41
  • Without copy and replace? Yes, may be able to use string merging `##` to do this, but I get really jumpy when I see stuff like this. – Michael Dorgan Jul 31 '18 at 17:41
  • 1
    To follow up, you don't include the "void " in your macro, but just ## an underscore to the beginning of the passed in value. – Michael Dorgan Jul 31 '18 at 17:44
  • You can achieve something similar to what you want by writing a `TRANSFORM_FUNC` macro which is implemented using the `#` operator inside. So, in your code you'd write something like: `TRANSFORM_FUNC(func)` and the prepocessor could generate the `void _func` for you. See this amazing answer for more details: https://stackoverflow.com/a/45376462/1212725 – bruceg Jul 31 '18 at 17:52
  • 1
    good luck when you start debugging it :) – 0___________ Jul 31 '18 at 18:07

0 Answers0