GNOME Bugzilla – Bug 85978
ambiguity error in drwabale.cc(g) with Sun Forte C++
Last modified: 2004-12-22 21:47:04 UTC
Compiling gdk/gdkmm/drawable.cc from gtkmm-1.3.16 with Sun Forte C++ (WS6U2 aka 5.3) results in ambiguity errors around Glib::unwrap: "drawable.cc", line 36: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 45: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 55: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 97: Warning (Anachronism): Assigning void(*)(void*,void*) to extern "C" void(*)(void*,void*). "drawable.cc", line 203: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 208: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 213: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 218: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 223: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 223: Error: Overloading ambiguity between "Glib::unwrap<Gdk::Drawable>(const Glib::RefPtr<const Gdk::Drawable>&)" and "Glib::unwrap<const Gdk::Drawable>(const Glib::RefPtr<const Gdk::Drawable>&)". "drawable.cc", line 228: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 228: Error: Overloading ambiguity between "Glib::unwrap<Gdk::Image>(const Glib::RefPtr<const Gdk::Image>&)" and "Glib::unwrap<const Gdk::Image>(const Glib::RefPtr<const Gdk::Image>&)". "drawable.cc", line 233: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 238: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 238: Error: Overloading ambiguity between "Glib::unwrap<Pango::Font>(const Glib::RefPtr<const Pango::Font>&)" and "Glib::unwrap<const Pango::Font>(const Glib::RefPtr<const Pango::Font>&)". "drawable.cc", line 243: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 243: Error: Overloading ambiguity between "Glib::unwrap<Pango::LayoutLine>(const Glib::RefPtr<const Pango::LayoutLine>&)" and "Glib::unwrap<const Pango::LayoutLine>(const Glib::RefPtr<const Pango::LayoutLine>&)". "drawable.cc", line 248: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 248: Error: Overloading ambiguity between "Glib::unwrap<Pango::LayoutLine>(const Glib::RefPtr<const Pango::LayoutLine>&)" and "Glib::unwrap<const Pango::LayoutLine>(const Glib::RefPtr<const Pango::LayoutLine>&)". "drawable.cc", line 253: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 253: Error: Overloading ambiguity between "Glib::unwrap<Pango::Layout>(const Glib::RefPtr<const Pango::Layout>&)" and "Glib::unwrap<const Pango::Layout>(const Glib::RefPtr<const Pango::Layout>&)". "drawable.cc", line 258: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 258: Error: Overloading ambiguity between "Glib::unwrap<Pango::Layout>(const Glib::RefPtr<const Pango::Layout>&)" and "Glib::unwrap<const Pango::Layout>(const Glib::RefPtr<const Pango::Layout>&)". "drawable.cc", line 278: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 283: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 288: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". These errors vanish by specializing the Glib::unwrap function call, e.g. @@ -33,7 +33,7 @@ { // Don't assume the reinterpret_cast<> works everywhere. Gdk::Point is *special*. gdk_draw_points( - gobj(), const_cast<GdkGC*>(Glib::unwrap(gc)), + gobj(), const_cast<GdkGC*>(Glib::unwrap<Gdk::GC>(gc)), reinterpret_cast<GdkPoint*>(const_cast<Point*>(points.data())), points.size()); } As I'm not sure that this is the right solution, I place it here instead of sending a patch against the CVS. Regards Michael
That seems acceptable. If I haven't done this in every place necessary, then please submit a real patch. Thanks.
It turns out that all of the cases were generated by _WRAP_METHODs in drawable.hg. How to handle this?
In one of the tools/m4/convert_*.m4 files. If you can't fix it yourself, then tell me what method has the problem now.
Do you need more help?
I might have fixed this, but I can't tell because I'm not using Sun's compiler. Please reopen if it's still a problem.
> I might have fixed this, but I can't tell because I'm not using > Sun's compiler. Please reopen if it's still a problem. No, its not fixed. Two cases in glyphstring.cc where added, see the complete error log from the current CVS below. I still patch this cases away by specialzing Gtk::unwrap with the non-const form of the ambiguous type. Because this code was generated by the _WRAP_METHODs, I really would like to see this fixed by the maintainers. I can send the whole working patch if required. -- "glyphstring.cc", line 131: Error: Overloading ambiguity between "Glib::unwrap<Pango::Font>(const Glib::RefPtr<const Pango::Font>&)" and "Glib::unwrap<const Pango::Font>(const Glib::RefPtr<const Pango::Font>&)". "glyphstring.cc", line 136: Error: Overloading ambiguity between "Glib::unwrap<Pango::Font>(const Glib::RefPtr<const Pango::Font>&)" and "Glib::unwrap<const Pango::Font>(const Glib::RefPtr<const Pango::Font>&)". 2 Error(s) detected. "drawable.cc", line 98: Warning (Anachronism): Assigning void(*)(void*,void*) to extern "C" void(*)(void*,void*). "drawable.cc", line 204: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 209: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 214: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 219: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 224: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 224: Error: Overloading ambiguity between "Glib::unwrap<Gdk::Drawable>(const Glib::RefPtr<const Gdk::Drawable>&)" and "Glib::unwrap<const Gdk::Drawable>(const Glib::RefPtr<const Gdk::Drawable>&)". "drawable.cc", line 229: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 229: Error: Overloading ambiguity between "Glib::unwrap<Gdk::Image>(const Glib::RefPtr<const Gdk::Image>&)" and "Glib::unwrap<const Gdk::Image>(const Glib::RefPtr<const Gdk::Image>&)". "drawable.cc", line 234: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 239: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 239: Error: Overloading ambiguity between "Glib::unwrap<Pango::Font>(const Glib::RefPtr<const Pango::Font>&)" and "Glib::unwrap<const Pango::Font>(const Glib::RefPtr<const Pango::Font>&)". "drawable.cc", line 244: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 244: Error: Overloading ambiguity between "Glib::unwrap<Pango::LayoutLine>(const Glib::RefPtr<const Pango::LayoutLine>&)" and "Glib::unwrap<const Pango::LayoutLine>(const Glib::RefPtr<const Pango::LayoutLine>&)". "drawable.cc", line 249: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 249: Error: Overloading ambiguity between "Glib::unwrap<Pango::LayoutLine>(const Glib::RefPtr<const Pango::LayoutLine>&)" and "Glib::unwrap<const Pango::LayoutLine>(const Glib::RefPtr<const Pango::LayoutLine>&)". "drawable.cc", line 254: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 254: Error: Overloading ambiguity between "Glib::unwrap<Pango::Layout>(const Glib::RefPtr<const Pango::Layout>&)" and "Glib::unwrap<const Pango::Layout>(const Glib::RefPtr<const Pango::Layout>&)". "drawable.cc", line 259: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 259: Error: Overloading ambiguity between "Glib::unwrap<Pango::Layout>(const Glib::RefPtr<const Pango::Layout>&)" and "Glib::unwrap<const Pango::Layout>(const Glib::RefPtr<const Pango::Layout>&)". "drawable.cc", line 279: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 284: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 289: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 294: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 299: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". "drawable.cc", line 304: Error: Overloading ambiguity between "Glib::unwrap<Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)" and "Glib::unwrap<const Gdk::GC>(const Glib::RefPtr<const Gdk::GC>&)". Compilation aborted, too many Error messages.
As I have said before, _WRAP_METHOD uses the conversions defined the tools/convert*.m4 files. Please look for the conversion in there and try to patch one of those files.
Created attachment 10127 [details] [review] patches to prevent ambiguity error with Sun's Forte C++ compiler
[I finally got it, thanks for your hints - still some comments] I have placed the macros __CONVERT_CONST_REFPTR_TO_P and __CONVERT_CONST_REFPTR_TO_P_SUN now in convert_base.m4 as they are used in several files (convert_{gdk,gtk,pango}.m4). The special handlings were added to convert_gdk.m4 and convert_pango.m4. The special handling with __CONVERT_CONST_REFPTR_TO_P_SUN for the types which were reclaimed by the Sun C++ compiler solves the problems for the moment. But I would advise to correct __CONVERT_CONST_REFPTR_TO_P in a more general way that it works for both g++ and Sun's Forte C++ compiler.
*** Bug 89451 has been marked as a duplicate of this bug. ***
Applied. Thanks. I would accept a patch that used this explicit template specalization for the standard __CONVERT_CONST_REFPTR_TO_P() and similar macros. You should keep the old definition there but comment it out, with your explanation.