kenmux
kenmux

Reputation: 151

How to #define function-like macro of the function with variable arguments in C

I have a function declared as:

int func(int a, int b, ...);

Then I want to #define a function-like macro as:

#define TEST(A,B) func(A,B,0)

But the compiler always complains: "error: expected declaration specifiers or '...', before numeric constant".

So, how can I eliminate this error?

Upvotes: 1

Views: 62

Answers (1)

Raghvendra Rao
Raghvendra Rao

Reputation: 156

Make sure the function is defined before the #define statement (could be imported too) so the compiler will the data type of a and b. Or you could also try type defining a and b as (int) a.

Upvotes: 1

Related Questions