Reputation: 53
I'm not posting the exact code here, but I have tried to represent the problem fully. I have the following macro -
#define TKN_PST(P) (ABC_##P)
This macro is called in the definition of another macro, which itself is called from another macro as below -
#define CREATE_TOKEN(P) FURTHER_PROC(P)
#define FURTHER_PROC(X) foo(a, b, TKN_PST(X), ...)
foo() is a function that accepts a variable number of arguments.
I'm getting an error when I call CREATE_TOKEN(P)
. The compiler tells me that ABC_
is undeclared.
This problem only occurs when I call CREATE_TOKEN(P)
, and doesn't occur for CREATE_TOKEN(Q)
, CREATE_TOKEN(R)
, etc. I suspect that this issue might be the result of P having a definition somewhere in the large code-base.
I tried introducing an extra level of indirection as below -
#define FURTHER_PROC(X) FURTHER_PROC2(X)
#define FURTHER_PROC2(X) foo(a, b, TKN_PST(X), ...)
Then CREATE_TOKEN(Q)
, CREATE_TOKEN(R)
, etc started failing with the error "')' expected before ...".
What might be the reason for this issue?
Upvotes: 1
Views: 123
Reputation: 53
Thanks to paulsm4 for pointing me in the right direction with his comment above.
I was able to find a definition (#define) for "P" in an included file, which has no replacement text. I hadn't considered this possibility.
Upvotes: 1