0

During calling of this fucntion what is the purpose of adding parentheses around void here?

  //Declaration
  Std_ReturnType IsoMgr_WriteErrorCode(/*IN*/const IsoMgr_ErrorCode_t ErrorCode);
  //Calling Instance
  (void)IsoMgr_WriteErrorCode(ErrorCode);
Has9
  • 41
  • 1
  • 7

2 Answers2

3

Some compilers may emit warnings when the return value of a function is not used.

This is a way to silence these warnings. It has no other purpose, and has no effect on the produced machine code.

Macmade
  • 52,708
  • 13
  • 106
  • 123
0

When you write

IsoMgr_WriteErrorCode(ErrorCode);

This line will ignore return value if any. Compiler don't know whether you as programmer are aware of this particular thing so warnings may be generated.

By writing void before function you inform compiler that you know you are ignoring return value and so want to emit any warnings due to that.

(void)IsoMgr_WriteErrorCode(ErrorCode);
Punit Vara
  • 3,744
  • 1
  • 16
  • 30