Hi,
Is there any way to pass a left parenthese or right parenthese as an argument to a function-like macro?
Thanks,
Printable View
Hi,
Is there any way to pass a left parenthese or right parenthese as an argument to a function-like macro?
Thanks,
You can pass it in a normal function as a char or as it's ascci code --> '('
thank you. I'm just curious when I read about cpp macro :) seems no way to implement that.
if this is what you want, it is possible with a trick. this seems to work. if you just put a literal non-string ) as the argument to M, the parser sees it as a closing paren and pukes. But if you do it with the #define P then that all gets substituted in before being parsed.
the Visual C preprocessor outputs thisCode:#define P )
#define M(a) f(a
void f(void)
{
}
int main(int argc,char *argv[])
{
M(P);
return 0;
}
Code:C:\home\dh0072\x\x1>cl /E x1.c
Microsoft (R) C/C++ Optimizing Compiler Version 17.00.50727.1 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
x1.c
#line 1 "x1.c"
void f(void)
{
}
int main(int argc,char *argv[])
{
f();
return 0;
}
@dmh2000, yes, great, that does the trick!
O_o
What are you trying to do?
Soma