Wextra fixes

Compiling with the -Wextra option with gcc/clang was giving a lot of warnings.

The last commit about unused variable warning was solved using compiler specific attributes as there doesn't seem to be a "standard" way of doing that.
I prefered this solution over the other common approach:
#define UNUSED(x) (void)(x);
because if for whatever reason we have to use the variable and forget to remove the macro, the compiler won't complain, it can confuse the reader.
I tested with gcc and clang, but can't for msvc, can someone confirm that it works there as well ?