lkml.org 
[lkml]   [2001]   [Jul]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: linux/macros.h(new) and linux/list.h(mod) ...
    Em Fri, Jul 06, 2001 at 12:08:55AM +0100, David Woodhouse escreveu:
    >
    > #define min(a,b) __magic_minfoo(a,b, __var##__LINE__, __var2##__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__);
    > }

    Have you looked at the preprocessor output?

    [acme@brinquedo /tmp]$ gcc -E a.c -o - # or 'cpp < a.c'
    # 1 "a.c"
    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__ ; }) , 11);
    }

    I didn't found a way to generate unique variable names using __LINE__

    - Arnaldo
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-03-22 12:56    [W:0.027 / U:95.364 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site