Semantic Macro - assigning a previous macro to another
I have this macro:
#define kPaxZoneW 105.0
I want to define a subsequent macro that always needs to have the same value but for semantic reasons, needs to have a different name. Can I get away with this after the previous definition?
#define kPaxZoneAFA kPaxZoneW
This wo开发者_如何学编程uld ensure that kPaxZoneAFA will always be equal to the value of kPaxZoneW.
Yes; when you do this, any use of kPaxZoneAFA
would be replaced first by kPaxZoneW
then by 105.0
.
Yes you can. When the preprocessor comes across your second declaration, it will assign it the value of your original macro.
This is done in most every framework for aliases to macros.
精彩评论