I want to do:
#define VERSION XY123
#define PRODUCT MyApplication_VERSION
so that PRODUCT is actually MyApplication_XY123. I have tried playing with the merge operator ## but with limited success...
#define VERSION XY123
#define PRODUCT MyApplication_##VERSION
=> MyApplication_VERSION
#define VERSION XY123
#define PRODUCT MyApplication_##(VERSION)
=> MyApplication_(XY123) - close but not quite
Is what I want possible?
The
##
operator acts before argument substitution has taken place. The classical solution is to use a helper:Token pasting works with arguments to macros. So try this
All problems in computer science can be solved by an extra level of indirection: