Compiler complaining about undeclared variable in macro

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

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

The macro is used later in the file.

However, the compiler complains:

error: undeclared (first used in this function).

This is really weird .. will I miss something obvious?

+6
source share
2 answers

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

 #define MY_MACRO(a, b,...) (...) 
+12
source

Remove the space between the macro name and the argument list. The space separates the head of the macro from the body, so it is considered as a macro without arguments, which expands into a list of desired arguments, followed by the desired body.

+5
source

Source: https://habr.com/ru/post/977612/


All Articles