PAGE2GO2 HOME | INTERNET NEWS

LeighExchange - Free Advertising Network Stock Research at Internet Speed Need Money Easy and Quick?

Re: Tricky macro manipulation

 List
Subject: Re: Tricky macro manipulation
Poster: Chris Thomasson
Date: Fri, 23 Mar 2007 21:10:26 -0500
Related Postings: 1 2 3 4 5
"Adrian Hawryluk" wrote in message news:u%RMh.3219$6z3.553@edtnps82...
> Does anyone know of a way to manipulate a macro list to remove either the
> beginning or the end element? I.e. Given:
>
> #define ELEMENTS EL(1) EL(2) EL(3)
>
> Is there any manipulation to get just EL(1) EL(2) out of ELEMENTS? [...]

#include

#define PLACE_X(x)x #define PLACE(x)PLACE_X(x) #define QUOTE_X(x)#x #define QUOTE(x)QUOTE_X(x) #define STRIPL_X(x, y)PLACE(x) #define STRIPL(x)PLACE(STRIPL_X)x #define STRIPR_X(x, y)PLACE(y) #define STRIPR(x)PLACE(STRIPR_X)x

#define MYLIST() (node1, (node2, (node3, null)))

#define MYLIST_X(l)\ STRIPL(l)STRIPL(STRIPR(l))

/*** Static API Declaration _________________________________***/ static char prompt_getchar(char const*); #define promptexit_getchar(vzmp_buf)\ ((int)prompt_getchar((vzmp_buf)))

/*** Static API Definition _________________________________***/

/* Entry -------------------*/ int main(void) { { printf("%s\n", QUOTE(MYLIST()));

printf("%s\n", QUOTE(MYLIST_X(MYLIST())));

} return promptexit_getchar("\n\n--- press to exit ---\n"); }

/* Displays a prompt and waits on getchar -------------------*/ char prompt_getchar(char const *buf) { printf("%s", buf); return getchar(); }

Does that work for you?

 

Page2Go2.com is not responsible for content of this message.