1

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?

2
  • It might be because the compiler doesn't know how to express 0 in a vararg since there's no type information to match against. Try (int) 0. Commented Aug 27, 2020 at 4:16
  • @tadman, nop, not work. Commented Aug 27, 2020 at 4:48

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Oops, I know why. there's another declaration int func(int a, int b);, which is the case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.