Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiler complaining of undeclared variable in a macro

Tags:

c

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?

like image 930
Iceman Avatar asked Nov 02 '14 16:11

Iceman


2 Answers

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,...) (...)
like image 164
Minh Mai Avatar answered Sep 23 '22 13:09

Minh Mai


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.

like image 38
pat Avatar answered Sep 24 '22 13:09

pat