Best way to suppress C warning “Unused variable x”? [duplicate]

(void) variable might work for some compilers.

For C++ code, also see Mailbag: Shutting up compiler warnings where Herb Sutter recommends using:

template<class T> void ignore( const T& ) { }

...

ignore(variable);

Leave a Comment