Re: pls expand this macro
- From: roberson@xxxxxxxxxxxxxxxxxx (Walter Roberson)
- Date: Sun, 30 Oct 2005 14:03:19 +0000 (UTC)
In article <4364C9B9.A1BE52CF@xxxxxxxxxxxxxxxxxxx>,
sathyashrayan <sathyashrayan@xxxxxxxxxxxxxxxxxxx> wrote:
>#define plural_text(n) &"s"[(1 == (n))]
>1) I try to understand the two macros plural_text and plural_text2.
>array subscripting is commutative
>so in the above we could expand the macros as plural_text n[1] = "s" .
No, there is no assignment done. (1 == (n)) is an expression which
produces a value which is either 0 or 1, and the string "s" is indexed
at that offset, and the address (&) of the result is taken.
&"s"[0] is a pointer to the 's' character in a string, but
&"s"[1] is a pointer to the nul that follows the 's'.
In other words the result is either the string "s" or the empty string.
>3) << operator in the macro plural_text2 used to move the string to the
>second one, in the above case
>it is "s". Correct?
No, treat the inside as an expression again and look at the offsets
into the string.
--
I was very young in those days, but I was also rather dim.
-- Christopher Priest
.
- References:
- pls expand this macro
- From: sathyashrayan
- pls expand this macro
- Prev by Date: Re: Avaliable symbol table library??
- Next by Date: Re: pls expand this macro
- Previous by thread: Re: pls expand this macro
- Next by thread: Re: pls expand this macro
- Index(es):
Relevant Pages
|