This macro initializes a critical section lock as a member of a struct when using an list initialization. It has to be used together with \c DECLARE_CRIT_SECTION_LOCK_IN_STRUCT() to work. This macro basically creates a member of the initialization list, including the trailing comma. If the lock is unnecessary because the architecture is single-core, this macro will not do anything. This means that if \c lock_name is still a member of the struct, \c lock_name will be uninitialized. Hence, this macro has to be used together with \c DECLARE_CRIT_SECTION_LOCK_IN_STRUCT() to correctly to declare or omit the struct member \c lock_name. Example usage:
{c}
...
#include "os/critical_section.h"
...
typedef struct protected_struct_t {
int member1;
DECLARE_CRIT_SECTION_LOCK_IN_STRUCT(my_lock)
int another_member;
};
...
protected_struct_t my_protected = {
.member1 = 0,
INIT_CRIT_SECTION_LOCK_IN_STRUCT(my_lock) // no comma!
another_member = 47,
};