[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: What's the purpose of these parentheses in the #define's?
- From: Philipp Janda <siffiejoe@...>
- Date: Mon, 26 Jan 2015 10:00:16 +0100
Am 26.01.2015 um 08:51 schröbte William Ahern:
On Sun, Jan 25, 2015 at 11:21:45PM -0600, Paige DePol wrote:
Niccolo Medici <firstname.lastname@example.org> wrote:
Yes, I know about *that*. But the macros I'm talking about look like
function calls. A comma (,) has the lowest precedence in C. So why do
we need the parentheses? Let me modify your example:
We are not talking about the comma operator here but the
argument/parameter delimiter for function-like macros, so the precedence
of the former is irrelevant anyway.
The macro arguments might themselves be comma expressions. So the
parentheses aren't useless.
You can't have comma expressions without parentheses in argument lists.
#define X(a, b) ...
X(1, 2); /* ok */
X(1, 2, 3); /* constraint violation: wrong number of arguments */
X((1, 2), 3); /* ok, using comma expression as first argument */