I have a datatype state_t contains members as shown below:
typedef struct
{
uint8_t id;
uint8_t * allowed_transitions;
bool status;
} state_t;
Now, I would like to define a macro, as below, for creating many states.
#define transitionArgs(...) __VA_ARGS__
/**@brief Macro for defining a states.
*
* @param _name Name of the instance.
* @param _id Identifier value integer
* @param _transitions Allowed transitions set of integers
*/
#define STATE_DEF(_name, _id, _transitions)
static state_t _name =
{
.id = _id;
.allowed_transitions = {transitionArgs _transitions};
.status = false;
}
When, I try to define state like here below:
#define STATE_DEF(sleep, 0, (0, 1, 2))
I get the following error: invalid token in macro parameter list
Any insight to the problem is very much appreciated.
Thanks
New contributor
maveli is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.