Trivial use of X-macros for printfs

suggest change
/* define a list of preprocessor tokens on which to call X */
#define X_123 X(1) X(2) X(3)

/* define X to use */
#define X(val) printf("X(%d) made this print\n", val);
X_123
#undef X
/* good practice to undef X to facilitate reuse later on */

This example will result in the preprocessor generating the following code:

printf("X(%d) made this print\n", 1);
printf("X(%d) made this print\n", 2);
printf("X(%d) made this print\n", 3);

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents