unable to know the use of the statement "(void) ipAddr; (void) port;" in Iotivity framework

74 views Asked by At

i was working on Iotivity framework, while tracing i was not able to know the use of these statements. iotivity-1.3.0/resource/csdk/stack/src/ocstack.c

i'm curious to know the usage...

OCStackResult OCInit(const char *ipAddr, uint16_t port, OCMode mode)
{
(void) ipAddr;
(void) port;
return OCInit1(mode, OC_DEFAULT_FLAGS, OC_DEFAULT_FLAGS);
}
1

There are 1 answers

1
Sourav Ghosh On BEST ANSWER

In the code

(void) ipAddr;
(void) port;

is a way to silence compiler warning about "unused" variables.

It comes handy when the APIs has to follow a certain pattern to accept a number of parameters to conform to some standard, but actually, in the code you do not use the variables anyway.