I have a preprocessor macro, called INSTR(…). It takes in a comma separated list of chars, and outputs a compile time constant number depending on the input. This macro currently works, and can be used like this:
enum Instructions
{
INSTRUCTION_1 = INSTR('i','n','s','t','r','_','1'), //2408996205L when evaluated
INSTRUCTION_2 = INSTR('i','n','s','t','r','_','2') //2408996172L when evaluated
};
This currently works as intended, but obviously looks a bit clunky. I was wondering if it is possible to turn a word (not necessarily a string literal) in the preprocessor, turn it into a list of characters like that and insert it into the INSTR(…) function at compile time?
I’ve tried using string literals like mentioned here but it won’t work at compile time.
13