duplicate designator is not allowed C/C++ (2906)

Hi,

There is code for vendor model element creation in nCS provided Chat client sample, as in below:

static struct bt_mesh_elem elements[] = {
	BT_MESH_ELEM(
		1,
		BT_MESH_MODEL_LIST(
			BT_MESH_MODEL_CFG_SRV,
			BT_MESH_MODEL_HEALTH_SRV(&health_srv, &health_pub)),
		BT_MESH_MODEL_LIST(BT_MESH_MODEL_CHAT_CLI(&chat))),
};

This works fine in "model_handler.c",

But when I import the same code to the file "model_handler.cpp", I get a build error saying 

On : 

BT_MESH_ELEM(

I cannot avoid C++ here, kindly suggest for me to solve this.
Thanks,
Ubaid
Parents
  • Hi,

    The slightly cludgy workaround to this problem is to make a C wrapper that interfaces the libraries that use designated initializers, and then only call the C wrapper from your C++ code. The C wrapper would have to refrain from using designated initializers. This might also help.

    I would suggest you take this issue to the #ble-mesh channel on zephyr's discord server. You will get more support for this kind of query there.

Reply
  • Hi,

    The slightly cludgy workaround to this problem is to make a C wrapper that interfaces the libraries that use designated initializers, and then only call the C wrapper from your C++ code. The C wrapper would have to refrain from using designated initializers. This might also help.

    I would suggest you take this issue to the #ble-mesh channel on zephyr's discord server. You will get more support for this kind of query there.

Children
No Data
Related