Iceman
Iceman

Reputation: 4362

Compiler complaining of undeclared variable in a macro

I am using a macro defined in the same source file as:

#define MY_MACRO (a, b,...) (...)

The macro is being used later in the file.

However, the compiler complains:

error: a undeclared (first use in this function).

It's really weird.. am I missing something obvious?

Upvotes: 8

Views: 4285

Answers (2)

Minh Mai
Minh Mai

Reputation: 216

I think the problem is that there is a SPACE between MY_MACRO and (a, b, ...). It should be like this:

#define MY_MACRO(a, b,...) (...)

Upvotes: 15

pat
pat

Reputation: 12749

Remove the space between the macro name and the argument list. The space separates the macro head from the body, so it is being treated as a macro with no arguments that expands into the desired argument list followed by the desired body.

Upvotes: 7

Related Questions