Any way to replace part of a word with a preprocessor?

I have something like this in objective-C class

@interface PREFIX_MyClass {
...
@end

and I would like to use a preprocessor to convert it:

@interface AwesomeMyClass {
...
@end

so something like

#define PREFIX_ Awesome

doesn't work because it's part of the word. Any other way? I know I can use something like this:

#define PrefixClass(NAME) Awesome##NAME

@interface PrefixClass(MyClass)

but I don’t like it because it interrupts the execution of the code and refers to the following dev tools (i.e.: Xcode in this case)

+5
source share
2 answers

It's not very elegant, but you can use a preprocessor to replace the entire class name, not just the part.

#define PREFIX_MyClass AwesomeMyClass
@interface PREFIX_MyClass

, , , . , , , .

#define ADD_PREFIX(name) Awesome##name
#define PREFIX_MyClass ADD_PREFIX(MyClass)
@interface PREFIX_MyClass

, , PREFIX_MyClass.

+2

, , . Xcode . , ( ):

enter image description here

, " ", , .

0

All Articles