I have the following macro which is supposed to get a struct CLEAR_ARG and set some values to it:
#define POLICY_ARG_SET((CLEAR_ARG), ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7, ARG8) \
CLEAR_ARG->arg1= ARG1 \
CLEAR_ARG->arg2 = ARG2; \
CLEAR_ARG->arg3 = ARG3; \
CLEAR_ARG->arg4 = ARG4; \
CLEAR_ARG->arg5 = ARG5; \
CLEAR_ARG->arg6 = ARG6; \
CLEAR_ARG->arg7 = ARG7; \
CLEAR_ARG->arg8 = ARG8;
But I get macro definition malformed for macro warning for some reason.
I used the macro without the brackets over the (CLEAR_ARG), and set the struct with
POLICY_ARG_SET((&clear_arg),...)
but I don’t want to always worry about the brackets. Why do I get this warning, and how can it be solved?
You have misplaced the parentheses. In the name and arguments you cannot use them, you need to use them in the definition (the part that gets expanded).
Change your macro to this and it should work:
Note, in your example
(CLEAR_ARG)->arg1 = ARG1;is missing a semi-colon (;) as well