Casting to void is used to suppress compiler warnings. The Standard says in §5.2.9/4 says,
Any expression can be explicitly converted to type “cv void.” The
expression value is discarded.
More Related Contents:
- Multi-character constant warnings
- Can I use the result of a comparison as an integer in C++?
- How do I compare chars (or strings) using void functions, also comparing chars that were taken from a struct array
- Implicit type conversion rules in C++ operators
- Selectively disable GCC warnings for only part of a translation unit
- Can I assume (bool)true == (int)1 for any C++ compiler?
- Converting a pointer into an integer
- C++ convert from 1 char to string?
- Does there exist a static_warning?
- Cast pointer to member function to normal pointer
- Why does C++ code missing a formal argument name in a function definition compile without warnings?
- What’s up with the thousands of warnings in standard headers in MSVC -Wall?
- Is using #pragma warning push/pop the right way to temporarily alter warning level?
- Is f(void) deprecated in modern C and C++? [duplicate]
- Reinterpret_cast vs. C-style cast
- How do you disable the unused variable warnings coming out of gcc in 3rd party code I do not wish to edit?
- C++ auto vs auto&
- Passing shared_ptr as shared_ptr
- g++ How to get warning on ignoring function return value
- Why cast a pointer to a float into a pointer to a long, then dereference?
- Why doesn’t this reinterpret_cast compile?
- variable or field declared void
- Understanding gsl::narrow implementation
- Why should I initialize member variables in the order they’re declared in?
- Should I use a C++ reinterpret_cast over a C-style cast?
- What is the modern, correct way to do type punning in C++?
- Why Doesn’t reinterpret_cast Force copy_n for Casts between Same-Sized Types?
- Why “not all control paths return a value” is warning and not an error?
- How to cast simple pointer to a multidimensional-array of fixed size?
- How can I extend a lexical cast to support enumerated types?