GNOME Bugzilla – Bug 89450
Impossible casts with Sun Forte C++
Last modified: 2004-12-22 21:47:04 UTC
From the actual CVS gtk/gtkmm/treestore.cc and gtk/gtkmm/liststore.cc give the following compile errors with Sun Forte C++: "liststore.cc", line 47: Error: Using static_cast to convert from const Gtk::TreeRow& to const Gtk::TreeIter& not allowed. "liststore.cc", line 65: Error: Using static_cast to convert from const Gtk::TreeRow& to const Gtk::TreeIter& not allowed. "liststore.cc", line 134: Warning (Anachronism): Assigning void(*)(void*,void*) to extern "C" void(*)(void*,void*). 2 Error(s) and 1 Warning(s) detected. make[5]: *** [liststore.lo] Error 1 "treestore.cc", line 46: Error: Using static_cast to convert from const Gtk::TreeRow& to const Gtk::TreeIter& not allowed. "treestore.cc", line 64: Error: Using static_cast to convert from const Gtk::TreeRow& to const Gtk::TreeIter& not allowed. "treestore.cc", line 156: Warning (Anachronism): Assigning void(*)(void*,void*) to extern "C" void(*)(void*,void*). I can solve the problem by using reinterpret_cast, but this might not be your intention. Please have look into it.
The first error line is this: TreeModel::iterator ListStore::insert(const Row& row) { return insert(static_cast<const iterator&>(row)); } Note that iterator is a typedef for TreeIter, and Row is a typedef for TreeRow, and that is calling the insert(const iterator& iter) override. So shouldn't that work even without the static_cast<>, because Row is an iterator? So maybe you should first try it without any explicit cast. If that works then please provide a patch. If that works then maybe the overide isn't needed at all anyway. I'm not sure whether it's obvious that the other override would work.
Your assumption was right, the cast are not required at all, with Sun Forte C++ at least. I can not see the points in liststore.hg/ccg or treestore.hg/ccg, where the code came from, so please give me a hint or fixed it by yourself.
Created attachment 10129 [details] [review] explicit casts removed in gtk/src/{list,tree}store.cc
Thanks. Applied. On the list I will ask people whether they think these overrides are necessary anyway. > I can not see the points in liststore.hg/ccg or treestore.hg/ccg, > where the code came from, so please give me a hint or fixed it by > yourself. I don't understand what you mean here. You just fixed it in the .ccg files. Do you mean some other problem?
> I don't understand what you mean here. You just fixed it > in the .ccg files. Do you mean some other problem? No, I had just overlooked the simple solution here.