Debug fixes

This fixes a bug I introduced in the minor-fixes branch, when I removed the name declaration of an apparently unused argument; the argument *is* in fact used in an ASSERT().

I've also changed one file in what looks like the right way (but needs checking) for when __DEBUG__ is defined.

Finally, I changed build rules to add -D__DEBUG__ to C and C++ build flags for debug builds.  This seems sensible, but definitely needs checking, e.g., on MSVC.  I haven't checked it with clang either; I will still do so.
I'm guessing __DEBUG__ hasn't been used in some time, so this is a bit of a risky change; some of the ASSERT() statements that were previously disabled may be out of date, but in harder to notice ways than the ones in export_variable_internal.cpp.

By the way, the compile flags set in CompilerOptions.cmake after "Some common stuff" are a little odd; only for RELWITHDEBINFO do they appear to actually change anything (-O2, CMake defaut, to -O3), and even then there's a duplication of NDEBUG which CMake sets anyway.