Out of interest:
#define _ACD 5, 5, 5, 30
#define DEFAULT_NETWORK_TOKEN_KEY_CLASS _ACD
#define DEFAULT_NETWORK_TOKEN_KEY { DEFAULT_NETWORK_TOKEN_KEY_CLASS }
Using DEFAULT_NETWORK_TOKEN_KEY_CLASS macro only, how to get _ACD stringified in a const unsigned char [].
const uint8 startMsg[] = ?? DEFAULT_NETWORK_TOKEN_KEY_CLASS ;
Will result _ACD only.
What will be the correct macro expansion for getting _ACD here.
In context of How to stringify macro having array as #define a_macro {5,7,7,97}?
(The standard disclaimer about not abusing the C preprocessor without a really good reason applies here.)
It’s certainly possible to do what you want to do. You need a
STRINGIFYmacro and a bit of macro indirection.Typically,
STRINGIFYis defined with one level of indirection, to allow the C preprocessor to expand its arguments before they undergo stringification. One implementation is:However, you’ll find that this isn’t enough:
Here,
STRINGIFY(DEFAULT_NETWORK_TOKEN_KEY_CLASS)expands toSTRINGIFY0(5,5,5,30), and the C preprocessor complains that you’ve givenSTRINGIFY0too many arguments.The solution is to delay the expansion of
_ACDso it only expands to5,5,5,30when you want it to. To do this, define it as a function-like macro:This way,
_ACDwill only be expanded when you “call” it:_ACD().DEFAULT_NETWORK_TOKEN_KEY_CLASSwill now expand to_ACD, and you have to expand it further by “calling” it:DEFAULT_NETWORK_TOKEN_KEY_CLASS().The following code illustrates the solution: