+ 1
Someone please trace this code because I am not able to understand the syntax itself for this code.
#define macro(r, a, v) v##a##r #define DECVAR macro(r, a, v) int main() { int DECVAR = 42; var++; printf("%d", var); return 0; }
2 Respostas
+ 5
The two hashes (##) symbol appearing in macro definitions is the token-pasting operator.
https://docs.microsoft.com/en-us/cpp/preprocessor/token-pasting-operator-hash-hash
Think of it as a way to stringify and concatenate arguments in a macro. In the code above, it is simply used to concatenate v, a, and r together to form var. When you compile the code, DECVAR gets replaced with macro(r, a, v), which then gets replaced with var. This gives us an int variable var, which stores 42. The value is incremented by 1 and printed.
+ 1
Thank You Hatsy Rei ! I understood now.