Token Parsing Macro

Token parsing macros are useful to avoid tying same thing multiple times.

For an example, if you have multiple function and some condition checking is required in all functions, this type of macro can be used.

Below code is an example:

#include <stdio.h>
#define TEST(var1, var2) \
void test_func_##var1##_##var2##_test(int i) \
{                                            \
    /* Common part can be written here */
    printf("%s(): var = %d\n", __func__, i);\

    /* Task function can be called here */

int main()
    return 0;

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s