All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
To: Neil Booth <neil@daikokuya.demon.co.uk>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>,
	David Woodhouse <dwmw2@infradead.org>,
	Daniel Phillips <phillips@bonn-fries.net>,
	Davide Libenzi <davidel@xmailserver.org>,
	linux-kernel@vger.kernel.org
Subject: Re: linux/macros.h(new) and linux/list.h(mod) ...
Date: Fri, 6 Jul 2001 19:02:28 -0300	[thread overview]
Message-ID: <20010706190228.C4521@conectiva.com.br> (raw)
In-Reply-To: <E15II3b-0003T8-00@the-village.bc.nu> <20010706183804.A13869@daikokuya.demon.co.uk>
In-Reply-To: <20010706183804.A13869@daikokuya.demon.co.uk>; from neil@daikokuya.demon.co.uk on Fri, Jul 06, 2001 at 06:38:04PM +0100

Em Fri, Jul 06, 2001 at 06:38:04PM +0100, Neil Booth escreveu:
> Alan Cox wrote:-
> 
> > #define min(a,b) __magic_minfoo(a,b, __var##__LINE__, __var2##__LINE__)
> > 
> > #define __magic_minfoo(A,B,C,D) \
> > 	{ typeof(A) C = (A)  .... }
> 
> No, that's buggy.  You need an extra level of indirection to expand
> __LINE__.  Arguments to ## are inserted in-place without expansion.

yes, so lets try with another indirection and see if I'm missing something
that you could clarify :)

[acme@brinquedo __attribute__]$ cat b.c
#define _min(a,b,line) __magic_minfoo(a,b, __var##line, __var2##line)
#define min(a,b) _min(a,b,__LINE__)

#define __magic_minfoo(A,B,C,D) \
       ({ typeof(A) C = (A); typeof(B) D = (B); C>D?D:C; })

void main(void)
{
      int __var11=5, __var211=7;

      printf("min(%d,%d) = %d (should be 11: %d)\n", __var11, __var211,
             min(__var11, __var211), __LINE__);
}
[acme@brinquedo __attribute__]$ cpp < b.c
# 1 ""
void main(void)
{
      int __var11=5, __var211=7;

      printf("min(%d,%d) = %d (should be 11: %d)\n", __var11, __var211,
             ({ typeof(   __var11   )   __var__LINE__   = (   __var11   );
typeof(    __var211   )   __var2__LINE__   = (    __var211   );
__var__LINE__  >  __var2__LINE__  ?  __var2__LINE__  :  __var__LINE__  ; })
, 12);
}
[acme@brinquedo __attribute__]$

- Arnaldo

  reply	other threads:[~2001-07-06 22:02 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-05 20:57 linux/macros.h(new) and linux/list.h(mod) Davide Libenzi
2001-07-05 21:31 ` David Woodhouse
2001-07-05 21:45   ` Davide Libenzi
2001-07-05 21:54     ` Hua Zhong
2001-07-05 21:58       ` David Woodhouse
2001-07-05 22:20         ` Hua Zhong
2001-07-05 22:06       ` Davide Libenzi
2001-07-05 22:10     ` J . A . Magallon
2001-07-05 22:33     ` Daniel Phillips
2001-07-05 22:43     ` David Woodhouse
2001-07-05 22:53       ` Davide Libenzi
2001-07-05 23:23         ` J . A . Magallon
2001-07-05 22:57       ` Alan Cox
2001-07-05 23:05         ` Matthew Dharm
2001-07-05 23:07           ` Alan Cox
2001-07-05 23:08         ` David Woodhouse
2001-07-06  1:51           ` Arnaldo Carvalho de Melo
2001-07-05 23:21         ` Davide Libenzi
     [not found]           ` <0107060149080M.03760@starship>
2001-07-05 23:54             ` Daniel Phillips
2001-07-06 17:38         ` Neil Booth
2001-07-06 22:02           ` Arnaldo Carvalho de Melo [this message]
2001-07-05 22:03 ` Kai Germaschewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010706190228.C4521@conectiva.com.br \
    --to=acme@conectiva.com.br \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=davidel@xmailserver.org \
    --cc=dwmw2@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neil@daikokuya.demon.co.uk \
    --cc=phillips@bonn-fries.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.