Nico_Robin
Nico_Robin

Reputation: 89

Macro identifier undeclared even if it is declared

I have this error coming up when I try to compile my C project.

error #20: identifier "someGetFunctionMacro" is undefined

This comes up at the line where I am using someGetFunctionMacroB() in my code.

variable = someGetFunctionMacroB();

But here is what someGetFunctionMacroB() is abstracting.

#define someGetFunctionMacro()      someGetFunction(param1)

#define someGetFunctionMacroA()     (someGetFunctionMacro == returnval1 ||\
                                     someGetFunctionMacro == returnval2 ||\
                                     someGetFunctionMacro == returnval3)


#define someGetFunctionMacroB()     someGetFunctionMacroC() && (someGetFunctionMacroA() == 1)

I do not understand why the error is coming out when clearly identifier someGetFunctionMacro is defined.

Upvotes: 0

Views: 441

Answers (1)

Some programmer dude
Some programmer dude

Reputation: 409482

Function-like macros must be used like functions, with parentheses and all.

So if you have a macro like

#define someGetFunctionMacro()      someGetFunction(param1)

you must "call" it like a function with the parentheses.

In the someGetFunctionMacroA macro definition you don't use someGetFunctionMacro correctly.

Upvotes: 3

Related Questions