The special level loader has been using __FUNCTION__ in error messages
for a few months now, but that is a gcc extension (evidently picked up
by other compilers since only Borland had an issue so far). The
standard way to do the same thing is with __func__, but that's C99 so
we should avoid it. (__FUNCTION__ came earlier; gcc supports both.)
This switches to convential C code to achieve the same effect, using
the name 'nhFunc' rather than __FUNCTION__:
void foo()
{
static const char nhFunc[] = "foo";
... code that might report problem in nhFunc ...
return;
}
This has only been added to the functions which actually reference it,
not a blanket intrusion into every routine. In special level loader's
case, the reference is hidden in the opvar_free() macro which is used
quite a lot.
At first I used a macro:
void foo()
{
#define nhFunc "foo"
... code that might report problem in nhFunc ...
return;
#undef nhFunc
}
but using an actual variable avoids duplicate copies of the function
name string when used more than once inside a given function, and it
can't accidentally carry over into the next function due to missing or
misspelled #undef.
If we someday switch alloc() to give more specific information than
__FILE__, the macro variation would be better since the function name
won't be used most of the time (ie, when MONITOR_HEAP isn't defined).