#include <opcodes.h>
const char *getOpcodeName(
uint8_t op
)
{
#define OPCODE(x, y) if((0x##y)==op) return "OP_" #x;
OPCODES
#undef OPCODE
return "OP_UNKNOWN";
}
Link to the code here: https://github.com/znort987/blockparser/blob/master/opcodes.cpp
Here is a link to the included opcodes.h
I understand this is just a strangely formatted function, however, I am wondering what exactly the *
at the beginning of the function name means. I assume it has something to do with pointers?
Also, how are the #undef
and #define
statements valid? There's no semicolon after either one, and one of them seems to be defined as a one-line function. What does (0x##y)
mean? What does return "OP_" #x
mean? I haven't ever come across syntax like this before.
I want to get into C++ more seriously, but it's very hard when looking at code to tell what exactly is going on. How can I learn the syntax and rules most effectively?