I’m trying to write an macro:
#define FCT( x ) fct( ($ ## x), (@ ## x).first_line, (@ ## x).first_column )
The output of the macro should look like in this example:
FCT(2) --> fct( $2, @2.first_line, @2.first_column )
Unfortunately this doesn’t work, the @ seems to lead to errors. Is this even possible with the C preprocessor?
At the moment I am using this macro:
#define FCT(x,y) fct( x, y.first_line, y.first_column )
FCT($2,@2) --> fct( $2, @2.first_line, @2.first_column )
That works and is short enough for me, but I asked me if the first macro is somehow possible.
In fact, MSVC accepts
$as a valid symbol for identifiers. As it was correctly stated above this should not be so according to the standard. The@is a preprocessor operator that should normally be applied to parameters of the macro. You cannot use it as part of an identifier. Is your output a C program?