Trivial use of X-macros for printfs

suggest change
#include <stdio.h>

/* A list of invocations. X is defined by the code that uses the list. */
#define X_123 X(1) X(2) X(3)

#define X(val) printf("X(%d) made this print\n", val);

int main(void)
{
    X_123
    return 0;
}

#undef X /* so a later list can define X differently */

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