I am writing a Bluetooth Mesh application using the nRF51 chip from Nordic Semiconductor and while looking at some examples I stumbled onto this pieces of code:
nrf_mesh_address_t address = {NRF_MESH_ADDRESS_TYPE_INVALID, 0, NULL};
address.type = NRF_MESH_ADDRESS_TYPE_GROUP;
address.value = GROUP_ADDRESS;
As i read this snippet address
is first defined with some variables which is immediately changed again.
Isn't this double defining unnecessary?
The definition of nrf_mesh_addrees_t
look like this:
typedef struct
{
nrf_mesh_address_type_t type;
uint16_t value;
const uint8_t* p_virtual_uuid;
} nrf_mesh_address_t;
My first thought was that p_virtual_uuid
was declared const
so it could not be changed after the definition, but i did not get a compile error when changing the code to this:
nrf_mesh_address_t address;
address.type = NRF_MESH_ADDRESS_TYPE_GROUP;
address.value = GROUP_ADDRESS;
address.p_virtual_uuid = NULL;
Are there any advantages to defining the variable twice with different variables?