Why is cast from NULL illegal?
- From: Lars Clausen <lrclause cs uiuc edu>
- To: gtk-list gnome org
- Subject: Why is cast from NULL illegal?
- Date: 18 Nov 2002 14:55:43 -0600
After changing Dia's code to have more static type checking, I'm getting a
number of errors about invalid casts from NULL. But surely NULL can be any
type, so any cast of it should be valid.
The function in question here is gtk_item_factory_get_item(), which despite
always returning NULL or a GtkMenuItem* has a return type of GtkWidget*.
After some nasty bugs caused by the lack of static type check for this, I
decided to make better use of the compilers typechecking. But if I say
GTK_MENU_ITEM(gtk_item_factory_get_item(...)), I get warnings whenever it
returns NULL. Having to check for NULL before casting would be
cumbersome.
So: Is there any good reason why the (or some) type check macros don't
consider NULL to be of their type?
-Lars
--
Lars Clausen (http://shasta.cs.uiuc.edu/~lrclause)| Hårdgrim of Numenor
"I do not agree with a word that you say, but I |----------------------------
will defend to the death your right to say it." | Where are we going, and
--Evelyn Beatrice Hall paraphrasing Voltaire | what's with the handbasket?
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]