'What is the "(x)" term in macro

I found a structure definition as shown below,

#define MAX_SIZE(x) 1

struct var
{

    int temp;
    int temp2[MAX_SIZE(temp)];

};

What does MAX_SIZE(temp) mean?.

What is the dimension of temp2 array?.



Solution 1:[1]

If you are curious what the preprocessor is doing, your compiler can generate the preprocessed file for you. For example, compile this with gcc -E try.c -o try.i and take a look at the output.

This fragment is small enough you can just do gcc -E try.c, but in general if you include anything the preprocessed output can get quite long.

This macro is pretty useless: anything you give it resolves to 1

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rob Latham