Problems with BLE Mesh in a C++ project.

I am using NCS Connect SDK version 2.6.0

I am trying to create an array of models and found a problem with using Zephry macros in C++ projects. My main.cpp is as below

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/mesh.h>
#include <zephyr/sys/printk.h>
int main(void)
{
printk("Hello Worlds! %s\n", CONFIG_BOARD);
static const struct bt_mesh_model models[] =
{
BT_MESH_MODEL_CFG_SRV,
};
return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

BT_MESH_MODEL_CFG_SRV is defined in cfg_srv.h as

Fullscreen
1
2
3
4
#define BT_MESH_MODEL_CFG_SRV \
BT_MESH_MODEL_CNT_CB(BT_MESH_MODEL_ID_CFG_SRV, \
bt_mesh_cfg_srv_op, NULL, \
NULL, 1, 0, &bt_mesh_cfg_srv_cb)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

BT_MESH_MODEL_CNT_CB is defined in access.h

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/**
* @brief Composition data SIG model entry with callback functions
* with specific number of keys & groups.
*
* This macro uses compound literal feature of C99 standard and thus is available only from C,
* not C++.
*
* @param _id Model ID.
* @param _op Array of model opcode handlers.
* @param _pub Model publish parameters.
* @param _user_data User data for the model.
* @param _keys Number of keys that can be bound to the model.
* Shall not exceed @kconfig{CONFIG_BT_MESH_MODEL_KEY_COUNT}.
* @param _grps Number of addresses that the model can be subscribed to.
* Shall not exceed @kconfig{CONFIG_BT_MESH_MODEL_GROUP_COUNT}.
* @param _cb Callback structure, or NULL to keep no callbacks.
*/
#define BT_MESH_MODEL_CNT_CB(_id, _op, _pub, _user_data, _keys, _grps, _cb) \
{ \
.id = (_id), \
.pub = _pub, \
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Which is where the problem lies. The macro is defined for C language only and cannot be used with a C++ compiler as it uses compound literals.

Does anyone have any suggestion to resolve this impase

Appreciate any suggestions.

Thanks