Possible Duplicate:
casting unused return values to void
What is the purpose of (void)
before a function call, for example
(void)func1();
I assume this is the same as simply calling func1();
Therefore is the (void)
call simply to let other programmers know that the return type will be ignored, for instance if func1()
had a return type of int
, or does the compiler perhaps perform some optimizations on the function? Perhaps there is another reason behind it altogether - is it even legal C++ or perhaps is it a remnant of C seen in some legacy code.
Thanks