If the function name is missing, as in the first example, then this is not a “parenthesis operator”. It is simply a syntax element of an expression that changes the relationship between operators and operands. In this case, he just does nothing. What you have is just an expression
"Hello world";
which evaluates a value of type char * , and this value is ignored. You can surround this expression with an extra pair ()
("Hello world");
which will not change anything.
Similarly, you can write
(5 + 3);
in the middle of your code and get an expression that evaluates to a value of 8 , which is immediately discarded.
Typically, compilers do not generate code for expression statements that have no side effects. In fact, in C, the result of each expression operator is discarded, so the only expressions that "make sense" are expressions with side effects. Compilers are usually pretty good at detecting catchy statements and dropping them (sometimes with a warning).
A warning can be annoying, so writing unsuccessful expressions to an expression like
"Hello world";
may not be a good idea. Typically, compilers recognize a void cast as a request not to generate this warning
(void) "Hello world";
So, you might consider redefining your macro accordingly.
Of course, using the above trace technique, you should remember that if you put something that has a side effect as an argument to your macro
trace("%d\n", i++);
then in the "disabled" form it will look as follows
("%d\n", i++);
(two subexpressions encoded by the comma operator in one expression). The side effect of increment i saved in this case; it is not disabled. All this is equivalent to simple
i++;
Also, if you use a function call as an argument
trace(get_trace_name());
the disconnected form will look like
(get_trace_name());
and the compiler may not be smart enough to realize that the call to get_trace_name() should be dropped. Therefore, be careful when using your macro. Avoid arguments with side effects, avoid arguments with function calls, unless, of course, you intend to save side effects when disabling the actual trace.