Character Operator #@

This page was translated by a robot.

If the character string precedes a macro parameter in a parameterized macro definition #@, this means that the macro parameter is not simply replaced with the passed argument, but that the passed code ' 'is interpreted as a character in single quotation marks, which is why this macro operator is also used affectionately known as the speller or, in English, the charizer . However, this macro operator is not available on every system.






i: 5
#include <stdio.h>
#define MESSAGE(x) printf("%c: %d\n", #@x, x)

int main(){
  int i = 5;
  MESSAGE(i);
  return 0;
}

Details

On the author's system, spelling is not built into the compiler. Nevertheless, below is the line as the preprocessor would translate it:

printf("%c: %d\n", 'i', i);
MESSAGE(i);

It should be noted that the string #@represents a macro operator, i.e. a combination of macro operands. In this case it is a unary macro operator that expects an operand on the right. Only macro parameters are explicitly valid as operands for spelling. If you try to use this macro operator elsewhere in the code, the compiler will report an error.