vendredi 3 décembre 2021

Why is the nested macro not unfolded?

I am using nested macro under gcc-9.3.1.

Here is the code.

#define A(_name) _name, _name, _name

#define P(_1, _2, _name, ...) _name

#define B(...) P(__VA_ARGS__, A(something))(__VA_ARGS__)

B(k)

I expected the B(k) converted to P(k, something, something, something)(k) at first and then converted into something(k).

However, compilier told me that two arguments were too few for P, which meant that A(something) was not unfolded.

Why is that? And how can I make it unfolded?

Aucun commentaire:

Enregistrer un commentaire