0

While reading a codebase I came across the following statement:

(void)data;

data is a char* type.

What does the above statement achieve?

digito_evo
  • 3,216
  • 2
  • 14
  • 42
  • 5
    It's a usual idiom to suppress warnings about unused parameters in functions. Effectively that statement does nothing. – πάντα ῥεῖ Aug 26 '22 at 06:51
  • 2
    There was no way to say a parameter or return value was unused before C++ 17 without using compiler/vendor-specific directives, so (void) was used to silence compiler warnings in a cross-compiler way. C++17 introduced [maybe_unused](https://en.cppreference.com/w/cpp/language/attributes/maybe_unused) for this – Panagiotis Kanavos Aug 26 '22 at 06:59

0 Answers0