Reputation: 8606
The following code gives error:
"pasting "f32_Q31" and "(" does not give a valid preprocessing token"
#define INIT_Q(N, name, val) \
name.value = f32_Q##N##(val);
#define f32_Q31(x) f32_Q(31,x)
INIT_Q31(name, val) INIT_Q(31, name, val)
INIT_Q25(name, val) INIT_Q(25, name, val)
Can this be fixed?
Upvotes: 1
Views: 657
Reputation: 170074
Because f32_Q31(
is not a single token, but two. The (
is a token in and of itself. The result of concatenation must be a single valid token.
If your intent is to initialize name.value
with the expansion of another macro, the following will do:
#define INIT_Q(N, name, val) \
name.value = f32_Q##N(val);
The macro name is what must be a valid token, not the whole expression.
As Sander De Dycker pointed out, you seem to have also omitted the define
from your last two macro definitions:
#define INIT_Q31(name, val) INIT_Q(31, name, val)
#define INIT_Q25(name, val) INIT_Q(25, name, val)
Upvotes: 3