Cast checking error messages



Forgive me if this has already been done to death, but currently in
their type debugging mode the various cast macros such as
GTK_TOGGLE_BUTTON (widget) just give a warning like:

Gtk-WARNING **: invalid cast from `GtkCheckMenuItem' to `GtkToggleButton'

Now I sort of assume that the idea is to run under a debugger to find
out where your error is but on my system (RH 5.2 Intel) this is
rather difficult: g_warn is a macro for g_log and if I try to set a
break point inside g_log gdb rather scarily gives me:

Function "g_log" not defined.

which makes me wonder if gcc is just inlining the whole thing. 

So how does one get some helpful information about where the problem
is? (I put in the error above deliberately of course but you know..).

Would it not be better to at least give people the option of having
the type checking functions say the filename and line number from
which they are called? Something like:

Gtk-WARNING **: invalid cast from `GtkCheckMenuItem' to `GtkToggleButton'
            **: in file "myfile.c" line 1234.


It's a simple change to put __LINE__ and __FILE__ into a couple of
macros.  I'm happy to make the change myself if people want to try it
out.

John

Who's trying to be a good citizen.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]