Disable compiler warnings about unused variables
December 22nd, 2007
You might know warnings like this very well:
MyDialog.cpp: In member function âvoid MyDialog::Init()â: MyDialog.cpp:79: warning: unused variable âbtnCloseâ
It’s a simple and nice features compilers offer us but when projects are growing also the number of unused variables, the ones that are volitional unused, is growing. If you want to keep a clear head anyway what variables are unmeant unused you can use the following template:
template<typename T> void ignore_unused(T const&) { }
Just put it into a file that is included at beginning. I usually have a glob.h which provides all defines and stuff like that to me.
Now you can determine yourself which variables shall not cause a warning:
ignore_unused(btnClose);






nice idea! thx
Comment by Jeff — December 23, 2007 @ 1:45 pm